-
Notifications
You must be signed in to change notification settings - Fork 0
WrenchHandler
WrenchHandler class can be used if you want to be able to use wrenches from other mods on your blocks. It has 2 methods, both of which are booleans.
holdingWrench
takes in a EntityPlayer, and isWrench
takes in an ItemStack. The holdingWrench
method uses the isWrench
method.
In an onBlockActivated
method of a block (which has an EntityPlayer parameter), you can use this feature for wrenches in general to do stuff to your block. The wrench from whatever mod should have the doesSneakBypassUse
method in it's class in order to work properly for sneaking usage.
if(player.isSneaking()) {
if(WrenchHandler.holdingWrench(player)) {
player.sendMessage(new TextComponentString("You're sneaking and holding a wrench!"));
}
}
Here it checks to see if you're sneaking, and if you're holding a wrench. Remember, that holdingWrench
method uses isWrench
to see if the item is a wrench, so you don't need to do a check for that yourself.