From 4addff892b892fc62c35f4b50e78ac9ccb7383b3 Mon Sep 17 00:00:00 2001 From: modmuss50 Date: Thu, 14 Feb 2019 15:58:33 +0000 Subject: [PATCH] Create a WrenchContext to allow for ic2 mod compat to register support for using ic2's wrench --- .../java/techreborn/items/tools/ItemWrench.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/techreborn/items/tools/ItemWrench.java b/src/main/java/techreborn/items/tools/ItemWrench.java index 83314f883..e99655c40 100644 --- a/src/main/java/techreborn/items/tools/ItemWrench.java +++ b/src/main/java/techreborn/items/tools/ItemWrench.java @@ -44,6 +44,9 @@ import techreborn.items.ItemTR; */ public class ItemWrench extends ItemTR implements IToolHandler { + //Set by TR mod compat + public static WrenchContext ic2WrenchContext; + public ItemWrench() { setUnlocalizedName("techreborn.wrench"); setMaxStackSize(1); @@ -52,6 +55,12 @@ public class ItemWrench extends ItemTR implements IToolHandler { @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { + if(ic2WrenchContext != null){ + EnumActionResult actionResult = ic2WrenchContext.onItemUse(player, world, pos, hand, facing, hitX, hitY, hitZ); + if(actionResult != EnumActionResult.FAIL){ + return actionResult; + } + } if (!world.isRemote && !PermissionAPI.hasPermission(player.getGameProfile(), RebornPermissions.WRENCH_BLOCK, new BlockPosContext(player, pos, world.getBlockState(pos), facing))) { return EnumActionResult.PASS; } @@ -71,4 +80,10 @@ public class ItemWrench extends ItemTR implements IToolHandler { } return true; } + + @FunctionalInterface + public interface WrenchContext { + EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, + EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ); + } }