diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ArchaeologyLootRecipe.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ArchaeologyLootRecipe.java index f0f4203b..d7b1673a 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ArchaeologyLootRecipe.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ArchaeologyLootRecipe.java @@ -72,14 +72,13 @@ public ArchaeologyLootRecipe(ClientArchaeologyLootTable loot) { } } if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) { - String modName = EMILootAgnos.getModName(loot.id.getNamespace()); - rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", archName.toString() + " " + modName); + rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", archName.toString()); } else { Text unknown = LText.translatable("emi_loot.archaeology.unknown"); rawTitle = LText.translatable("emi_loot.archaeology.unknown_archaeology", archName.toString() + " " + unknown.getString()); } if (EMILoot.config.isLogI18n(EMILoot.Type.ARCHAEOLOGY)) { - EMILoot.LOGGER.warn("Untranslated archaeology loot table \"" + loot.id + "\" (key: \"" + key + "\")"); + EMILoot.LOGGER.warn("Untranslated archaeology loot table \"{}\" (key: \"{}\")", loot.id, key); } } else { rawTitle = text; @@ -143,7 +142,9 @@ public void addWidgets(WidgetHolder widgets) { } widgets.addText(title.title(), 1, 0, 0x404040, false); - if (title.trimmed()) { + if (EMILootAgnos.isModLoaded(loot.id.getNamespace())) { + widgets.addTooltip(LText.components(title.rawTitle(), loot.id.getNamespace()), 0, 0, 144, 10); + } else { widgets.addTooltipText(List.of(title.rawTitle()), 0, 0, 144, 10); } AtomicInteger index = new AtomicInteger(lootStacksSortedSize); diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java index 098d7ab8..a0fdf5c5 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/ChestLootRecipe.java @@ -71,14 +71,13 @@ public ChestLootRecipe(ClientChestLootTable loot) { } } if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) { - String modName = EMILootAgnos.getModName(loot.id.getNamespace()); - rawTitle = LText.translatable("emi_loot.chest.unknown_chest", chestName.toString() + " " + modName); + rawTitle = LText.translatable("emi_loot.chest.unknown_chest", chestName.toString()); } else { Text unknown = LText.translatable("emi_loot.chest.unknown"); rawTitle = LText.translatable("emi_loot.chest.unknown_chest", chestName.toString() + " " + unknown.getString()); } if (EMILoot.config.isLogI18n(EMILoot.Type.CHEST)) { - EMILoot.LOGGER.warn("Untranslated chest loot table \"" + loot.id + "\" (key: \"" + key + "\")"); + EMILoot.LOGGER.warn("Untranslated chest loot table \"{}\" (key: \"{}\")", loot.id, key); } } else { rawTitle = text; @@ -146,7 +145,9 @@ public void addWidgets(WidgetHolder widgets) { finalRowHeight = 18; } widgets.addText(title.title(), 1, 0, 0x404040, false); - if (title.trimmed()) { + if (EMILootAgnos.isModLoaded(loot.id.getNamespace())) { + widgets.addTooltip(LText.components(title.rawTitle(), loot.id.getNamespace()), 0, 0, 144, 10); + } else { widgets.addTooltipText(List.of(title.rawTitle()), 0, 0, 144, 10); } AtomicInteger index = new AtomicInteger(lootStacksSortedSize); diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/GameplayLootRecipe.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/GameplayLootRecipe.java index 0e3ae2cb..8da48d65 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/GameplayLootRecipe.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/GameplayLootRecipe.java @@ -63,8 +63,7 @@ public GameplayLootRecipe(ClientGameplayLootTable loot) { } } if(EMILootAgnos.isModLoaded(loot.id.getNamespace())) { - String modName = EMILootAgnos.getModName(loot.id.getNamespace()); - rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", gameplayName.toString() + " " + modName); + rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", gameplayName.toString()); } else { Text unknown = LText.translatable("emi_loot.gameplay.unknown"); rawTitle = LText.translatable("emi_loot.gameplay.unknown_gameplay", gameplayName.toString() + " " + unknown.getString()); @@ -166,8 +165,10 @@ public void addWidgets(WidgetHolder widgets) { //draw the gameplay name widgets.addText(name.title(), 0, 0, 0x404040, false); - if (name.trimmed()) { - widgets.addTooltipText(List.of(name.rawTitle()), 0, 0, EMILoot.config.isTooltipStyle() ? 144 : 154, 10); + if (EMILootAgnos.isModLoaded(loot.id.getNamespace())) { + widgets.addTooltip(LText.components(name.rawTitle(), loot.id.getNamespace()), 0, 0, 144, 10); + } else { + widgets.addTooltipText(List.of(name.rawTitle()), 0, 0, 144, 10); } if (EMILoot.config.isTooltipStyle()) { List stacks = (outputStacks.size() <= 4 || !EMILoot.config.isCompact(EMILoot.Type.GAMEPLAY)) diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/MobLootRecipe.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/MobLootRecipe.java index 49342bbb..f1a70d66 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/MobLootRecipe.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/emi/MobLootRecipe.java @@ -200,6 +200,7 @@ public void addWidgets(WidgetHolder widgets) { int offset = ClientResourceData.MOB_OFFSETS.getOrDefault(type, 0); widgets.addTexture(EmiTexture.LARGE_SLOT, x, y); widgets.addDrawable(x, y, 16, 16, (matrices, mx, my, delta) -> inputStack.render(matrices, 5, 6 + offset, delta)); + widgets.addTooltip(inputStack.getTooltip(), x, y, 24, 24); } //draw the name, moved over if the spawn egg is available diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/BlockStateEmiStack.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/BlockStateEmiStack.java index 27390779..1c9b2f18 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/BlockStateEmiStack.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/BlockStateEmiStack.java @@ -1,14 +1,17 @@ package fzzyhmstrs.emi_loot.util; +import dev.emi.emi.api.render.EmiTooltipComponents; import dev.emi.emi.api.stack.EmiStack; import fzzyhmstrs.emi_loot.EMILootClientAgnos; import net.minecraft.block.BlockState; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.nbt.NbtCompound; import net.minecraft.registry.Registries; import net.minecraft.text.Text; import net.minecraft.util.Identifier; +import java.util.ArrayList; import java.util.List; public class BlockStateEmiStack extends EmiStack { @@ -53,7 +56,15 @@ public Identifier getId() { @Override public List getTooltipText() { - return List.of(Registries.BLOCK.get(id).getName()); + return List.of(state.getBlock().getName()); + } + + @Override + public List getTooltip() { + ArrayList list = new ArrayList<>(); + list.add(EmiTooltipComponents.of(state.getBlock().getName())); + EmiTooltipComponents.appendModName(list, id.getNamespace()); + return list; } @Override diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/EntityEmiStack.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/EntityEmiStack.java index 97f33a45..31bab60e 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/EntityEmiStack.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/EntityEmiStack.java @@ -106,8 +106,7 @@ public List getTooltip() { List list = new ArrayList<>(); if (entity != null) { list.addAll(getTooltipText().stream().map(Text::asOrderedText).map(TooltipComponent::of).toList()); - String mod = EMILootAgnos.getModName(Registries.ENTITY_TYPE.getId(entity.getType()).getNamespace()); - list.add(TooltipComponent.of(Text.literal(mod).formatted(Formatting.BLUE).formatted(Formatting.ITALIC).asOrderedText())); + EmiTooltipComponents.appendModName(list, Registries.ENTITY_TYPE.getId(entity.getType()).getNamespace()); if (!getRemainder().isEmpty()) { list.add(EmiTooltipComponents.getRemainderTooltipComponent(this)); } diff --git a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/LText.java b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/LText.java index e4152d34..37312a7d 100644 --- a/xplat/src/main/java/fzzyhmstrs/emi_loot/util/LText.java +++ b/xplat/src/main/java/fzzyhmstrs/emi_loot/util/LText.java @@ -1,7 +1,9 @@ package fzzyhmstrs.emi_loot.util; +import dev.emi.emi.api.render.EmiTooltipComponents; import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; +import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.screen.ScreenTexts; import net.minecraft.text.MutableText; import net.minecraft.text.OrderedText; @@ -9,6 +11,7 @@ import net.minecraft.text.Text; import net.minecraft.util.Language; +import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -35,6 +38,13 @@ public class LText { "archaeology" )); + public static List components(Text title, String namespace) { + ArrayList components = new ArrayList<>(); + components.add(EmiTooltipComponents.of(title)); + EmiTooltipComponents.appendModName(components, namespace); + return components; + } + public static MutableText translatable(String key) { return Text.translatable(key); }