From d95ea5b1172b42cb3df9b0ec7e343c60ed46f107 Mon Sep 17 00:00:00 2001 From: huige <61108540+huige233@users.noreply.github.com> Date: Tue, 10 May 2022 00:48:34 +0800 Subject: [PATCH] tooltip --- src/main/java/huige233/transcend/Main.java | 1 + .../huige233/transcend/items/tools/ToolSword.java | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/huige233/transcend/Main.java b/src/main/java/huige233/transcend/Main.java index 3395814..35d2b31 100644 --- a/src/main/java/huige233/transcend/Main.java +++ b/src/main/java/huige233/transcend/Main.java @@ -1,6 +1,7 @@ package huige233.transcend; import huige233.transcend.gui.ModGuiElementLoader; +import huige233.transcend.items.tools.ToolSword; import huige233.transcend.proxy.CommonProxy; import huige233.transcend.util.Reference; import huige233.transcend.world.Worldgen; diff --git a/src/main/java/huige233/transcend/items/tools/ToolSword.java b/src/main/java/huige233/transcend/items/tools/ToolSword.java index d8014d2..a68aa0f 100644 --- a/src/main/java/huige233/transcend/items/tools/ToolSword.java +++ b/src/main/java/huige233/transcend/items/tools/ToolSword.java @@ -6,9 +6,7 @@ import huige233.transcend.init.ModItems; import huige233.transcend.items.fireimmune; import huige233.transcend.lib.TranscendDamageSources; -import huige233.transcend.util.ArmorUtils; -import huige233.transcend.util.IHasModel; -import huige233.transcend.util.TextUtils; +import huige233.transcend.util.*; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; @@ -30,12 +28,12 @@ import net.minecraftforge.common.util.EnumHelper; import net.minecraftforge.event.entity.player.ItemTooltipEvent; import net.minecraftforge.fml.common.Loader; +import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Optional; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import vazkii.botania.api.mana.ICreativeManaProvider; import vazkii.botania.api.mana.IManaItem; import vazkii.botania.api.mana.IManaTooltipDisplay; -import huige233.transcend.util.ItemNBTHelper; import java.util.List; import java.util.UUID; @@ -43,6 +41,7 @@ @Optional.Interface(iface="vazkii.botania.api.mana.IManaItem",modid="botania") @Optional.Interface(iface="vazkii.botania.api.mana.IManaTooltipDisplay",modid="botania") @Optional.Interface(iface="vazkii.botania.api.mana.ICreativeManaProvider",modid="botania") +@Mod.EventBusSubscriber(modid = Reference.MOD_ID) public class ToolSword extends ItemSword implements IHasModel, ICreativeManaProvider, IManaItem, IManaTooltipDisplay { private static final ToolMaterial TRANSCEND_SWORD = EnumHelper.addToolMaterial("TRANSCEND_SWORD", 32, -1, 9999.0f, 32763F, 10000); @@ -109,12 +108,13 @@ public Entity createEntity(World world,Entity location, ItemStack itemstack) { } @SubscribeEvent - public void onTooltip(ItemTooltipEvent event){ + public static void onTooltip(ItemTooltipEvent event){ if(event.getItemStack().getItem() instanceof ToolSword) { for (int x = 0; x < event.getToolTip().size(); ++x) { if (((String) event.getToolTip().get(x)).contains(I18n.translateToLocal("attribute.name.generic.attackDamage")) || ((String) event.getToolTip().get(x)).contains(I18n.translateToLocal("Attack Damage"))) { if (event.getItemStack().getItem() == ModItems.TRANSCEND_SWORD) { - event.getToolTip().set(1, TextFormatting.BLUE + "+" + TextUtils.makeFabulous(I18n.translateToLocal("tip.transcend")) + " " + TextFormatting.BLUE + I18n.translateToLocal("attribute.name.generic.attackDamage")); + event.getToolTip().set(x, TextFormatting.BLUE + "+" + TextUtils.makeFabulous(I18n.translateToLocal("tip.transcend")) + " " + TextFormatting.BLUE + I18n.translateToLocal("attribute.name.generic.attackDamage")); + event.getToolTip().set(x+1, TextFormatting.BLUE + "+" + TextUtils.makeFabulous(I18n.translateToLocal("tip.transcend")) + " " + TextFormatting.BLUE + I18n.translateToLocal("attribute.name.generic.reachDistance")); } return; }