diff --git a/patches/minecraft/net/minecraft/util/text/TextComponentTranslation.java.patch b/patches/minecraft/net/minecraft/util/text/TextComponentTranslation.java.patch new file mode 100644 index 000000000..5f4daaf74 --- /dev/null +++ b/patches/minecraft/net/minecraft/util/text/TextComponentTranslation.java.patch @@ -0,0 +1,13 @@ +--- a/net/minecraft/util/text/TextComponentTranslation.java ++++ b/net/minecraft/util/text/TextComponentTranslation.java +@@ -101,6 +101,10 @@ + } + } + ++ if (j == 0) { ++ // if we failed to match above, lets try the messageformat handler instead. ++ j = net.minecraftforge.fml.TextComponentMessageFormatHandler.handle(this, this.field_150278_b, this.field_150277_e, p_150269_1_); ++ } + if (j < p_150269_1_.length()) { + ITextComponent itextcomponent1 = new TextComponentString(String.format(p_150269_1_.substring(j))); + itextcomponent1.func_150256_b().func_150221_a(this.func_150256_b()); diff --git a/src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java b/src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java new file mode 100644 index 000000000..ab1a80d57 --- /dev/null +++ b/src/main/java/net/minecraftforge/fml/TextComponentMessageFormatHandler.java @@ -0,0 +1,18 @@ +package net.minecraftforge.fml; + +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentString; +import net.minecraft.util.text.TextComponentTranslation; + +import java.util.List; + +public class TextComponentMessageFormatHandler { + public static int handle(final TextComponentTranslation parent, final List children, final Object[] formatArgs, final String format) { + try { + children.add(new TextComponentString(ForgeI18n.parseFormat(format, formatArgs))); + return format.length(); + } catch (IllegalArgumentException ex) { + return 0; + } + } +}