From 96607760e1903eb34c535ab7f7756e5f27a8910d Mon Sep 17 00:00:00 2001 From: Blood-Asp Date: Sun, 19 Jun 2016 18:23:28 +0200 Subject: [PATCH] EnderIO Wrench Support --- .../api/items/GT_MetaGenerated_Tool.java | 27 ++++++++++++++++--- .../items/GT_MetaGenerated_Tool_01.java | 4 +-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java index ca862c2c..cfbf9deb 100644 --- a/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java +++ b/src/main/java/gregtech/api/items/GT_MetaGenerated_Tool.java @@ -4,6 +4,7 @@ import buildcraft.api.tools.IToolWrench; import cpw.mods.fml.common.Optional; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; +import crazypants.enderio.api.tool.ITool; import forestry.api.arboriculture.IToolGrafter; import gregtech.api.GregTech_API; import gregtech.api.enchants.Enchantment_Radioactivity; @@ -54,8 +55,8 @@ import static gregtech.api.enums.GT_Values.MOD_ID_RC; * This is an example on how you can create a Tool ItemStack, in this case a Bismuth Wrench: * GT_MetaGenerated_Tool.sInstances.get("gt.metatool.01").getToolWithStats(16, 1, Materials.Bismuth, Materials.Bismuth, null); */ -@Optional.InterfaceList(value = {@Optional.Interface(iface = "forestry.api.arboriculture.IToolGrafter", modid = MOD_ID_FR), @Optional.Interface(iface = "mods.railcraft.api.core.items.IToolCrowbar", modid = MOD_ID_RC), @Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft")}) -public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IDamagableItem, IToolGrafter, IToolCrowbar, IToolWrench { +@Optional.InterfaceList(value = {@Optional.Interface(iface = "forestry.api.arboriculture.IToolGrafter", modid = MOD_ID_FR), @Optional.Interface(iface = "mods.railcraft.api.core.items.IToolCrowbar", modid = MOD_ID_RC), @Optional.Interface(iface = "buildcraft.api.tools.IToolWrench", modid = "BuildCraft"), @Optional.Interface(iface = "crazypants.enderio.api.tool.ITool", modid = "EnderIO")}) +public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IDamagableItem, IToolGrafter, IToolCrowbar, IToolWrench, ITool { /** * All instances of this Item Class are listed here. * This gets used to register the Renderer to all Items of this Type, if useStandardMetaItemRenderer() returns true. @@ -517,7 +518,7 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements if(player.getCurrentEquippedItem()==null)return false; if (!isItemStackUsable(player.getCurrentEquippedItem())) return false; IToolStats tStats = getToolStats(player.getCurrentEquippedItem()); - return tStats != null && tStats.isCrowbar(); + return tStats != null && tStats.isWrench(); } @Override @@ -527,6 +528,26 @@ public abstract class GT_MetaGenerated_Tool extends GT_MetaBase_Item implements IToolStats tStats = getToolStats(player.getCurrentEquippedItem()); if (tStats != null) doDamage(player.getCurrentEquippedItem(), tStats.getToolDamagePerEntityAttack()); } + + @Override + public boolean canUse(ItemStack stack, EntityPlayer player, int x, int y, int z){ + return canWrench(player, x, y, z); + } + + @Override + public void used(ItemStack stack, EntityPlayer player, int x, int y, int z){ + wrenchUsed(player, x, y, z); + } + + @Override + public boolean shouldHideFacades(ItemStack stack, EntityPlayer player) { + if(player==null)return false; + if(player.getCurrentEquippedItem()==null)return false; + if (!isItemStackUsable(player.getCurrentEquippedItem())) return false; + IToolStats tStats = getToolStats(player.getCurrentEquippedItem()); + return tStats.isWrench(); + } + @Override public boolean canLink(EntityPlayer aPlayer, ItemStack aStack, EntityMinecart cart) { diff --git a/src/main/java/gregtech/common/items/GT_MetaGenerated_Tool_01.java b/src/main/java/gregtech/common/items/GT_MetaGenerated_Tool_01.java index 5f6ef0c6..090357f5 100644 --- a/src/main/java/gregtech/common/items/GT_MetaGenerated_Tool_01.java +++ b/src/main/java/gregtech/common/items/GT_MetaGenerated_Tool_01.java @@ -6,12 +6,12 @@ import gregtech.api.items.GT_MetaGenerated_Tool; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.common.tools.*; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -public class GT_MetaGenerated_Tool_01 - extends GT_MetaGenerated_Tool { +public class GT_MetaGenerated_Tool_01 extends GT_MetaGenerated_Tool { public static final short SWORD = 0; public static final short PICKAXE = 2; public static final short SHOVEL = 4;