diff --git a/src/main/java/com/micle/totemofreviving/items/StrawTotemItem.java b/src/main/java/com/micle/totemofreviving/items/StrawTotemItem.java index b5966b4..981a98e 100755 --- a/src/main/java/com/micle/totemofreviving/items/StrawTotemItem.java +++ b/src/main/java/com/micle/totemofreviving/items/StrawTotemItem.java @@ -4,6 +4,7 @@ import com.micle.totemofreviving.TotemOfReviving; import com.micle.totemofreviving.network.C2SRequestPlayerRevive; import com.micle.totemofreviving.network.C2SRequestTotemCharge; import com.micle.totemofreviving.network.C2SRequestTotemTarget; +import com.micle.totemofreviving.setup.ModKeyMappings; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; @@ -25,13 +26,13 @@ public class StrawTotemItem extends Item { public static final String TAG_TARGET_NAME = "target_name"; public static final String TAG_FAIL_CHANCE = "fail_chance"; public static final int STARTING_FAIL_CHANCE = 45; - private static final KeyMapping KEY_LSHIFT = new KeyMapping("StrawTotemItem_LSHIFT", InputConstants.KEY_LSHIFT, KeyMapping.CATEGORY_INTERFACE); public StrawTotemItem() { super(new Item.Properties().tab(CreativeModeTab.TAB_MISC).stacksTo(1).rarity(Rarity.UNCOMMON)); } @Override + @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack stack, Level world, List tooltip, TooltipFlag flag) { super.appendHoverText(stack, world, tooltip, flag); tooltip.add(new TextComponent(ChatFormatting.GOLD + "Charges: " + ChatFormatting.GRAY + stack.getOrCreateTag().getInt(TAG_CHARGE_AMOUNT))); @@ -39,7 +40,7 @@ public class StrawTotemItem extends Item { tooltip.add(new TextComponent(ChatFormatting.GOLD + "Fail Chance: " + ChatFormatting.GRAY + stack.getOrCreateTag().getInt(TAG_FAIL_CHANCE))); tooltip.add(new TextComponent( ChatFormatting.DARK_GRAY + "" + ChatFormatting.ITALIC + "\"Feels kinda funky.\"")); tooltip.add(new TextComponent("")); - if (KEY_LSHIFT.isDown()) { + if (ModKeyMappings.KEYMAP_UI_LSHIFT.isDown()) { tooltip.add(new TextComponent(ChatFormatting.YELLOW + "R-CLICK")); tooltip.add(new TextComponent(ChatFormatting.GOLD + "When other hand is empty: attempt to revive target.")); tooltip.add(new TextComponent(ChatFormatting.GOLD + "When other hand has " + ChatFormatting.GRAY + "Straw Reviving Charge" + ChatFormatting.GOLD + ": charge totem.")); diff --git a/src/main/java/com/micle/totemofreviving/items/TotemOfRevivingItem.java b/src/main/java/com/micle/totemofreviving/items/TotemOfRevivingItem.java index 68c36c7..01a389d 100755 --- a/src/main/java/com/micle/totemofreviving/items/TotemOfRevivingItem.java +++ b/src/main/java/com/micle/totemofreviving/items/TotemOfRevivingItem.java @@ -4,6 +4,7 @@ import com.micle.totemofreviving.TotemOfReviving; import com.micle.totemofreviving.network.C2SRequestPlayerRevive; import com.micle.totemofreviving.network.C2SRequestTotemCharge; import com.micle.totemofreviving.network.C2SRequestTotemTarget; +import com.micle.totemofreviving.setup.ModKeyMappings; import com.mojang.blaze3d.platform.InputConstants; import net.minecraft.ChatFormatting; import net.minecraft.client.KeyMapping; @@ -23,20 +24,20 @@ public class TotemOfRevivingItem extends Item { public static final String TAG_CHARGE_AMOUNT = "charge"; public static final String TAG_TARGET_INDEX = "target_index"; public static final String TAG_TARGET_NAME = "target_name"; - private static final KeyMapping KEY_LSHIFT = new KeyMapping("TotemOfRevivingItem_LSHIFT", InputConstants.KEY_LSHIFT, KeyMapping.CATEGORY_INTERFACE); public TotemOfRevivingItem() { super(new Item.Properties().tab(CreativeModeTab.TAB_MISC).stacksTo(1).rarity(Rarity.RARE)); } @Override + @OnlyIn(Dist.CLIENT) public void appendHoverText(ItemStack stack, Level world, List tooltip, TooltipFlag flag) { super.appendHoverText(stack, world, tooltip, flag); tooltip.add(new TextComponent(ChatFormatting.DARK_AQUA + "Charges: " + ChatFormatting.BLUE + stack.getOrCreateTag().getInt(TAG_CHARGE_AMOUNT)) { }); tooltip.add(new TextComponent(ChatFormatting.DARK_AQUA + "Target: " + ChatFormatting.BLUE + stack.getOrCreateTag().getString(TAG_TARGET_NAME))); tooltip.add(new TextComponent("")); - if (KEY_LSHIFT.isDown()) { + if (ModKeyMappings.KEYMAP_UI_LSHIFT.isDown()) { tooltip.add(new TextComponent(ChatFormatting.AQUA + "R-CLICK")); tooltip.add(new TextComponent(ChatFormatting.DARK_AQUA + "When other hand is empty: attempt to revive target.")); tooltip.add(new TextComponent(ChatFormatting.DARK_AQUA + "When other hand has " + ChatFormatting.BLUE + "Reviving Charge" + ChatFormatting.DARK_AQUA + ": charge totem.")); diff --git a/src/main/java/com/micle/totemofreviving/setup/ModKeyMappings.java b/src/main/java/com/micle/totemofreviving/setup/ModKeyMappings.java new file mode 100644 index 0000000..ccca7e9 --- /dev/null +++ b/src/main/java/com/micle/totemofreviving/setup/ModKeyMappings.java @@ -0,0 +1,8 @@ +package com.micle.totemofreviving.setup; + +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.KeyMapping; + +public class ModKeyMappings { + public static final KeyMapping KEYMAP_UI_LSHIFT = new KeyMapping("KEYMAP_UI_LSHIFT", InputConstants.KEY_LSHIFT, KeyMapping.CATEGORY_INTERFACE); +}