Only unicorns can see what a specific gem does

This commit is contained in:
Sollace 2021-03-02 20:12:57 +02:00
parent a50cc0d117
commit 51b541091e
2 changed files with 15 additions and 2 deletions

View file

@ -16,8 +16,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup; import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText; import net.minecraft.text.TranslatableText;
import net.minecraft.util.Formatting;
import net.minecraft.util.Hand; import net.minecraft.util.Hand;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.TypedActionResult; import net.minecraft.util.TypedActionResult;
@ -31,13 +33,19 @@ public class GemstoneItem extends Item {
} }
@Override @Override
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> list, TooltipContext tooltipContext) { public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> lines, TooltipContext tooltipContext) {
if (isEnchanted(stack)) { if (isEnchanted(stack)) {
SpellType<?> key = getSpellKey(stack); SpellType<?> key = getSpellKey(stack);
Affinity affinity = getAffinity(stack); Affinity affinity = getAffinity(stack);
list.add(new TranslatableText(key.getTranslationKey(affinity) + ".lore").formatted(affinity.getColor())); MutableText line = new TranslatableText(key.getTranslationKey(affinity) + ".lore").formatted(affinity.getColor());
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) {
line = line.formatted(Formatting.OBFUSCATED);
}
lines.add(line);
} }
} }
@ -63,6 +71,10 @@ public class GemstoneItem extends Item {
@Override @Override
public Text getName(ItemStack stack) { public Text getName(ItemStack stack) {
if (isEnchanted(stack)) { if (isEnchanted(stack)) {
if (!Unicopia.SIDE.getPlayerSpecies().canCast()) {
return new TranslatableText(getTranslationKey(stack) + ".obfuscated");
}
return new TranslatableText(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName(getAffinity(stack))); return new TranslatableText(getTranslationKey(stack) + ".enchanted", getSpellKey(stack).getName(getAffinity(stack)));
} }
return super.getName(); return super.getName();

View file

@ -32,6 +32,7 @@
"item.unicopia.crystal_shard": "Crystal Shard", "item.unicopia.crystal_shard": "Crystal Shard",
"item.unicopia.gemstone": "Gemstone", "item.unicopia.gemstone": "Gemstone",
"item.unicopia.gemstone.enchanted": "%s Gem", "item.unicopia.gemstone.enchanted": "%s Gem",
"item.unicopia.gemstone.obfuscated": "Mysterious Gem",
"item.unicopia.pegasus_feather": "Pegasus Feather", "item.unicopia.pegasus_feather": "Pegasus Feather",
"item.unicopia.gryphon_feather": "Gryphon Feather", "item.unicopia.gryphon_feather": "Gryphon Feather",