Fix getUnformattedDeepText breaking with translation text components, which resulted in double tooltip text

This commit is contained in:
grimmauld 2020-11-17 14:58:48 +01:00
parent d16f41ccfb
commit 20d1403ede

View file

@ -29,12 +29,7 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.TieredItem; import net.minecraft.item.TieredItem;
import net.minecraft.util.IItemProvider; import net.minecraft.util.IItemProvider;
import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.*;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.Style;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TextProcessing;
public class TooltipHelper { public class TooltipHelper {
@ -284,11 +279,10 @@ public class TooltipHelper {
public static String getUnformattedDeepText(ITextComponent component) { public static String getUnformattedDeepText(ITextComponent component) {
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
b.append(component.getString()); if (!(component instanceof TranslationTextComponent))
b.append(component.getString());
component.getSiblings() component.getSiblings()
.forEach(c -> { .forEach(c -> b.append(getUnformattedDeepText(c)));
b.append(getUnformattedDeepText(c));
});
return b.toString(); return b.toString();
} }