diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/WailaPluginVanilla.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/WailaPluginVanilla.java index 12f3e2961..baed1b7e5 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/WailaPluginVanilla.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/WailaPluginVanilla.java @@ -30,6 +30,7 @@ import mcp.mobius.waila.plugin.vanilla.provider.JukeboxProvider; import mcp.mobius.waila.plugin.vanilla.provider.MobTimerProvider; import mcp.mobius.waila.plugin.vanilla.provider.NoteBlockProvider; +import mcp.mobius.waila.plugin.vanilla.provider.PandaProvider; import mcp.mobius.waila.plugin.vanilla.provider.PetOwnerProvider; import mcp.mobius.waila.plugin.vanilla.provider.PlantProvider; import mcp.mobius.waila.plugin.vanilla.provider.PlayerHeadProvider; @@ -45,6 +46,7 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.OwnableEntity; +import net.minecraft.world.entity.animal.Panda; import net.minecraft.world.entity.animal.horse.AbstractHorse; import net.minecraft.world.entity.decoration.ItemFrame; import net.minecraft.world.entity.item.FallingBlockEntity; @@ -111,10 +113,12 @@ public void register(IRegistrar registrar) { registrar.addConfig(Options.ATTRIBUTE_LONG_ARMOR_MAX, 100); registrar.addMergedConfig(Options.ATTRIBUTE_HORSE_JUMP_HEIGHT, true); registrar.addMergedConfig(Options.ATTRIBUTE_HORSE_SPEED, true); + registrar.addMergedConfig(Options.ATTRIBUTE_PANDA_GENES, true); registrar.addComponent(BlockAttributesProvider.INSTANCE, BODY, Block.class, 950); registrar.addComponent(EntityAttributesProvider.INSTANCE, HEAD, Entity.class, 950); registrar.addComponent(EntityAttributesProvider.INSTANCE, BODY, Entity.class, 950); registrar.addComponent(HorseProvider.INSTANCE, BODY, AbstractHorse.class); + registrar.addComponent(PandaProvider.INSTANCE, BODY, Panda.class); registrar.addEntityData(EntityAttributesProvider.INSTANCE, Entity.class); registrar.addMergedSyncedConfig(Options.JUKEBOX_RECORD, true, false); diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java index 4be4ece11..951c944c2 100644 --- a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/config/Options.java @@ -43,6 +43,7 @@ public final class Options { public static final ResourceLocation ATTRIBUTE_LONG_ARMOR_MAX = rl("attribute.long_armor_max"); public static final ResourceLocation ATTRIBUTE_HORSE_JUMP_HEIGHT = rl("attribute.horse_jump_height"); public static final ResourceLocation ATTRIBUTE_HORSE_SPEED = rl("attribute.horse_speed"); + public static final ResourceLocation ATTRIBUTE_PANDA_GENES = rl("attribute.panda_genes"); public static final ResourceLocation BOOK_BOOKSHELF = rl("book.bookshelf"); public static final ResourceLocation BOOK_WRITTEN = rl("book.written"); public static final ResourceLocation BOOK_ENCHANTMENT_DISPLAY_MODE = rl("book.enchantment"); diff --git a/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java new file mode 100644 index 000000000..7d89e9426 --- /dev/null +++ b/src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java @@ -0,0 +1,42 @@ +package mcp.mobius.waila.plugin.vanilla.provider; + +import mcp.mobius.waila.api.IEntityAccessor; +import mcp.mobius.waila.api.IEntityComponentProvider; +import mcp.mobius.waila.api.IPluginConfig; +import mcp.mobius.waila.api.ITooltip; +import mcp.mobius.waila.api.component.PairComponent; +import mcp.mobius.waila.buildconst.Tl; +import mcp.mobius.waila.plugin.vanilla.config.Options; +import net.minecraft.ChatFormatting; +import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.MutableComponent; +import net.minecraft.world.entity.animal.Panda; + +public enum PandaProvider implements IEntityComponentProvider { + + INSTANCE; + + @Override + public void appendBody(ITooltip tooltip, IEntityAccessor accessor, IPluginConfig config) { + if (!config.getBoolean(Options.ATTRIBUTE_PANDA_GENES)) return; + + Panda panda = accessor.getEntity(); + var personality = panda.getVariant(); + var mainGene = panda.getMainGene(); + var hiddenGene = panda.getHiddenGene(); + + tooltip.addLine(new PairComponent( + Component.translatable(Tl.Tooltip.Panda.PERSONALITY), + geneText(personality))); + tooltip.addLine(new PairComponent( + Component.translatable(Tl.Tooltip.Panda.TRAITS), + Component.empty().append(geneText(mainGene)).append(", ").append(geneText(hiddenGene)))); + } + + private static MutableComponent geneText(Panda.Gene gene) { + var text = Component.translatable(Tl.Tooltip.Panda.GENE + "." + gene.getSerializedName()); + if (gene.isRecessive()) text.withStyle(ChatFormatting.RED); + return text; + } + +} diff --git a/src/resources/resources/assets/waila/lang/en_us.json b/src/resources/resources/assets/waila/lang/en_us.json index 3e455bc85..1af17244a 100644 --- a/src/resources/resources/assets/waila/lang/en_us.json +++ b/src/resources/resources/assets/waila/lang/en_us.json @@ -23,6 +23,16 @@ "tooltip.waila.horse.speed.key" : "Speed", "tooltip.waila.horse.speed.value" : "%s m/s", + "tooltip.waila.panda.personality" : "Personality", + "tooltip.waila.panda.traits" : "Traits", + "tooltip.waila.panda.gene.normal" : "Normal", + "tooltip.waila.panda.gene.lazy" : "Lazy", + "tooltip.waila.panda.gene.worried" : "Worried", + "tooltip.waila.panda.gene.playful" : "Playful", + "tooltip.waila.panda.gene.brown" : "Brown", + "tooltip.waila.panda.gene.weak" : "Weak", + "tooltip.waila.panda.gene.aggressive" : "Aggressive", + "tooltip.waila.instrument.harp" : "Harp", "tooltip.waila.instrument.basedrum" : "Bass Drum", "tooltip.waila.instrument.snare" : "Snare Drum", @@ -232,6 +242,7 @@ "config.waila.plugin_minecraft.attribute.long_armor_max_desc" : "The maximum armor points that the icon will draw before forcing numeric view", "config.waila.plugin_minecraft.attribute.horse_jump_height" : "Show Horse Jump Height", "config.waila.plugin_minecraft.attribute.horse_speed" : "Show Horse Speed", + "config.waila.plugin_minecraft.attribute.panda_genes" : "Show Panda Genes", "config.waila.plugin_minecraft.book" : "Book", "config.waila.plugin_minecraft.book.bookshelf" : "Show Chiseled Bookshelf Books", "config.waila.plugin_minecraft.book.written" : "Show Written Book Author and Generation", @@ -304,5 +315,6 @@ "theme.waila.plugin_waila.nine_patch.mode_tile" : "Tile", "tooltip.waila.instrument" : "_DO_NOT_TRANSLATE_", + "tooltip.waila.panda.gene" : "_DO_NOT_TRANSLATE_", "config.waila.plugin_" : "_DO_NOT_TRANSLATE_" }