Skip to content

Commit

Permalink
tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
huige233 committed May 9, 2022
1 parent 04e7df9 commit d95ea5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/main/java/huige233/transcend/Main.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/huige233/transcend/items/tools/ToolSword.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,19 +28,20 @@
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;

@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);

Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit d95ea5b

Please sign in to comment.