Fix tooltips showing 'LB' instead of putting the new line on well a new line.

This commit is contained in:
alexbegt committed 2019-10-03 19:52:44 -04:00
1 parent 74dde2ef0e
commit 15fa7022dd
2 files changed
+22 -5

No files matched your search

@@ -55,7 +55,7 @@ public class EdibleItem extends Item implements IGeneratedJson {
if (this.displayEffectsTooltip) {
for (Pair<EffectInstance, Float> pair : stack.getItem().getFood().getEffects()) {
if (pair.getLeft() != null) {
tooltip.add(new StringTextComponent(TextFormatting.GRAY.toString() + I18n.format(pair.getLeft().getEffectName()).trim()));
tooltip.add(new StringTextComponent(I18n.format(pair.getLeft().getEffectName()).trim()).applyTextStyle(TextFormatting.GRAY));
}
}
}
@@ -1,15 +1,16 @@
package slimeknights.mantle.item;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import slimeknights.mantle.util.LocUtils;
import net.minecraftforge.fml.ForgeI18n;
import javax.annotation.Nullable;
import java.util.List;
@@ -29,8 +30,24 @@ public class TooltipItem extends Item {
}
public static void addOptionalTooltip(ItemStack stack, List<ITextComponent> tooltip) {
if (I18n.hasKey(stack.getTranslationKey() + ".tooltip")) {
tooltip.addAll(LocUtils.getTooltips(TextFormatting.GRAY.toString() + LocUtils.translateRecursive(stack.getTranslationKey() + ".tooltip")));
String translationKey = stack.getTranslationKey() + ".tooltip";
if (!ForgeI18n.getPattern(translationKey).equals(translationKey)) {
String translate = ForgeI18n.getPattern(translationKey);
if (!ForgeI18n.getPattern(translate).equals(translate)) {
String[] strings = new TranslationTextComponent(translate).getFormattedText().split("\n");
for (String string : strings) {
tooltip.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY));
}
}
else {
String[] strings = new TranslationTextComponent(translationKey).getFormattedText().split("\n");
for (String string : strings) {
tooltip.add(new StringTextComponent(string).applyTextStyle(TextFormatting.GRAY));
}
}
}
}
}