-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #178
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/pluginVanilla/java/mcp/mobius/waila/plugin/vanilla/provider/PandaProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters