From 182fead64d7a617afc962900ccaf4ea44cd409d0 Mon Sep 17 00:00:00 2001 From: tterrag1098 Date: Sat, 4 Oct 2014 18:49:45 -0400 Subject: [PATCH] Add IToolHammer to Yeta wrench so it can wrench TE machines. --- src/main/java/cofh/api/item/IToolHammer.java | 44 +++++++++++++++++++ src/main/java/cofh/api/item/package-info.java | 10 +++++ .../crazypants/enderio/item/IYetaWrench.java | 8 ++++ .../enderio/item/ItemYetaWrench.java | 28 +++++++++--- 4 files changed, 83 insertions(+), 7 deletions(-) create mode 100644 src/main/java/cofh/api/item/IToolHammer.java create mode 100644 src/main/java/cofh/api/item/package-info.java create mode 100644 src/main/java/crazypants/enderio/item/IYetaWrench.java diff --git a/src/main/java/cofh/api/item/IToolHammer.java b/src/main/java/cofh/api/item/IToolHammer.java new file mode 100644 index 00000000..1ffefe72 --- /dev/null +++ b/src/main/java/cofh/api/item/IToolHammer.java @@ -0,0 +1,44 @@ +package cofh.api.item; + +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on subclasses of Item to have that item work as a tool for CoFH mods. + */ +public interface IToolHammer { + + /** + * Called to ensure that the wrench can be used. + * + * @param item + * The itemstack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) + * @param user + * The entity using the tool + * @param x + * X location of the block/tile + * @param y + * Y location of the block/tile + * @param z + * Z location of the block/tile + * @return True if this tool can be used + */ + boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z); + + /** + * Callback for when the tool has been used reactively. + * + * @param item + * The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) + * @param user + * The entity using the tool + * @param x + * X location of the block/tile + * @param y + * Y location of the block/tile + * @param z + * Z location of the block/tile + */ + void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z); + +} diff --git a/src/main/java/cofh/api/item/package-info.java b/src/main/java/cofh/api/item/package-info.java new file mode 100644 index 00000000..49608fd1 --- /dev/null +++ b/src/main/java/cofh/api/item/package-info.java @@ -0,0 +1,10 @@ +/** + * (C) 2014 Team CoFH / CoFH / Cult of the Full Hub + * http://www.teamcofh.com + */ +@API(apiVersion = CoFHAPIProps.VERSION, owner = "CoFHAPI", provides = "CoFHAPI|item") +package cofh.api.item; + +import cofh.api.CoFHAPIProps; +import cpw.mods.fml.common.API; + diff --git a/src/main/java/crazypants/enderio/item/IYetaWrench.java b/src/main/java/crazypants/enderio/item/IYetaWrench.java new file mode 100644 index 00000000..7ba807a3 --- /dev/null +++ b/src/main/java/crazypants/enderio/item/IYetaWrench.java @@ -0,0 +1,8 @@ +package crazypants.enderio.item; + +import cofh.api.item.IToolHammer; +import buildcraft.api.tools.IToolWrench; + +public interface IYetaWrench extends IToolWrench, IToolHammer{ + +} diff --git a/src/main/java/crazypants/enderio/item/ItemYetaWrench.java b/src/main/java/crazypants/enderio/item/ItemYetaWrench.java index d73e416d..9415e74e 100644 --- a/src/main/java/crazypants/enderio/item/ItemYetaWrench.java +++ b/src/main/java/crazypants/enderio/item/ItemYetaWrench.java @@ -1,7 +1,9 @@ package crazypants.enderio.item; +import cofh.api.item.IToolHammer; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -18,7 +20,7 @@ import crazypants.enderio.config.Config; import crazypants.enderio.gui.IResourceTooltipProvider; import crazypants.enderio.network.PacketHandler; -public class ItemYetaWrench extends Item implements IToolWrench, IResourceTooltipProvider { +public class ItemYetaWrench extends Item implements IYetaWrench, IResourceTooltipProvider { public static ItemYetaWrench create() { if(Config.useSneakMouseWheelYetaWrench) { @@ -71,7 +73,14 @@ public class ItemYetaWrench extends Item implements IToolWrench, IResourceToolti ConduitDisplayMode.setDisplayMode(equipped, newMode); return equipped; } + + @Override + public boolean isFull3D() { + return true; + } + /* IYetaWrench */ + @Override public boolean canWrench(EntityPlayer player, int x, int y, int z) { return true; @@ -86,15 +95,20 @@ public class ItemYetaWrench extends Item implements IToolWrench, IResourceToolti public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { return true; } + + @Override + public boolean isUsable(ItemStack item, EntityLivingBase user, int x, int y, int z) { + return true; + } + + @Override + public void toolUsed(ItemStack item, EntityLivingBase user, int x, int y, int z) { + ; + } + /* IResourceTooltipProvider */ @Override public String getUnlocalizedNameForTooltip(ItemStack stack) { return getUnlocalizedName(); } - - @Override - public boolean isFull3D() { - return true; - } - }