for emphasis

This commit is contained in:
yrsegal@gmail.com 2022-05-29 16:11:23 -04:00
parent 61e208a1d8
commit 718225b3cc
2 changed files with 20 additions and 4 deletions

View file

@ -4,9 +4,12 @@ import at.petrak.hexcasting.api.item.ManaHolderItem;
import net.minecraft.ChatFormatting; import net.minecraft.ChatFormatting;
import net.minecraft.advancements.Advancement; import net.minecraft.advancements.Advancement;
import net.minecraft.network.chat.Component; import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextColor;
import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayer;
import net.minecraft.util.Mth;
import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResultHolder; import net.minecraft.world.InteractionResultHolder;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
@ -38,6 +41,7 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
@Override @Override
public void setMana(ItemStack stack, int mana) { public void setMana(ItemStack stack, int mana) {
// NO-OP
} }
@Override @Override
@ -47,7 +51,7 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
@Override @Override
public boolean canRecharge(ItemStack stack) { public boolean canRecharge(ItemStack stack) {
return true; return false;
} }
@Override @Override
@ -80,11 +84,22 @@ public class ItemCreativeUnlocker extends Item implements ManaHolderItem {
return InteractionResultHolder.success(player.getItemInHand(usedHand)); return InteractionResultHolder.success(player.getItemInHand(usedHand));
} }
private static MutableComponent rainbow(MutableComponent component, Level level) {
if (level == null) {
return component.withStyle(ChatFormatting.WHITE);
}
return component.withStyle((s) ->
s.withColor(TextColor.fromRgb(Mth.hsvToRgb(level.getGameTime() * 2 % 360 / 360F, 1F, 1F))));
}
@Override @Override
public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents, public void appendHoverText(ItemStack stack, @Nullable Level level, List<Component> tooltipComponents,
TooltipFlag isAdvanced) { TooltipFlag isAdvanced) {
tooltipComponents.add(new TranslatableComponent("item.hexcasting.creative_unlocker.tooltip.0").withStyle(ChatFormatting.GRAY)); String prefix = "item.hexcasting.creative_unlocker.";
tooltipComponents.add(new TranslatableComponent("item.hexcasting.creative_unlocker.tooltip.1").withStyle(ChatFormatting.GRAY)); tooltipComponents.add(new TranslatableComponent(prefix + "tooltip.0", rainbow(new TranslatableComponent(prefix + "for_emphasis"), level)
.withStyle(ChatFormatting.GRAY)));
tooltipComponents.add(new TranslatableComponent(prefix + "tooltip.1").withStyle(ChatFormatting.GRAY));
} }
private static void addChildren(Advancement root, List<Advancement> out) { private static void addChildren(Advancement root, List<Advancement> out) {

View file

@ -58,7 +58,8 @@
"item.hexcasting.pride_colorizer_13": "Aroace Pigment", "item.hexcasting.pride_colorizer_13": "Aroace Pigment",
"item.hexcasting.uuid_colorizer": "Soulglimmer Pigment", "item.hexcasting.uuid_colorizer": "Soulglimmer Pigment",
"item.hexcasting.creative_unlocker": "Creative Unlocker", "item.hexcasting.creative_unlocker": "Creative Unlocker",
"item.hexcasting.creative_unlocker.tooltip.0": "Contains INFINITE MEDIA.", "item.hexcasting.creative_unlocker.for_emphasis": "INFINITE MEDIA",
"item.hexcasting.creative_unlocker.tooltip.0": "Contains %s.",
"item.hexcasting.creative_unlocker.tooltip.1": "Right-click to unlock all Hexcasting advancements and abilities.", "item.hexcasting.creative_unlocker.tooltip.1": "Right-click to unlock all Hexcasting advancements and abilities.",