Skip to content

Commit

Permalink
add panda genes tooltip
Browse files Browse the repository at this point in the history
closes #178
  • Loading branch information
deirn committed Aug 28, 2023
1 parent 0a7da11 commit 96591e6
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}

}
12 changes: 12 additions & 0 deletions src/resources/resources/assets/waila/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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_"
}

0 comments on commit 96591e6

Please sign in to comment.