Create a WrenchContext to allow for ic2 mod compat to register support for using ic2's wrench
This commit is contained in:
parent
8e34062f6e
commit
4addff892b
1 changed files with 15 additions and 0 deletions
|
@ -44,6 +44,9 @@ import techreborn.items.ItemTR;
|
||||||
*/
|
*/
|
||||||
public class ItemWrench extends ItemTR implements IToolHandler {
|
public class ItemWrench extends ItemTR implements IToolHandler {
|
||||||
|
|
||||||
|
//Set by TR mod compat
|
||||||
|
public static WrenchContext ic2WrenchContext;
|
||||||
|
|
||||||
public ItemWrench() {
|
public ItemWrench() {
|
||||||
setUnlocalizedName("techreborn.wrench");
|
setUnlocalizedName("techreborn.wrench");
|
||||||
setMaxStackSize(1);
|
setMaxStackSize(1);
|
||||||
|
@ -52,6 +55,12 @@ public class ItemWrench extends ItemTR implements IToolHandler {
|
||||||
@Override
|
@Override
|
||||||
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
|
public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
|
||||||
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
|
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))) {
|
if (!world.isRemote && !PermissionAPI.hasPermission(player.getGameProfile(), RebornPermissions.WRENCH_BLOCK, new BlockPosContext(player, pos, world.getBlockState(pos), facing))) {
|
||||||
return EnumActionResult.PASS;
|
return EnumActionResult.PASS;
|
||||||
}
|
}
|
||||||
|
@ -71,4 +80,10 @@ public class ItemWrench extends ItemTR implements IToolHandler {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface WrenchContext {
|
||||||
|
EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos,
|
||||||
|
EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue