Create a WrenchContext to allow for ic2 mod compat to register support for using ic2's wrench

This commit is contained in:
modmuss50 2019-02-14 15:58:33 +00:00
parent 8e34062f6e
commit 4addff892b

View file

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