I need an event that either triggers on right click AFTER block interaction or for some way to do that with the PlayerInteractEvent. I want it to be like the onItemUse method in items that triggers after block interaction or if the player is holding shift.
I did originally have the code in an item, but the item is meant to override a vanilla item with a new function and that's not possible with 1.7.
The following code it what I currently have for my PlayerInteractEvent. I've tried manually triggering the activation then canceling the event after (to prevent activation from happening twice, too) but it seems to cause other problems like no more chest animations or sound.
If anyone could help me with this, that'd be great.
Thanks
Code:
@SubscribeEvent
public void onRightClick(PlayerInteractEvent e)
{
if (e.isCanceled())
{
return;
}
if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_AIR )
{
this.throwBrickEvent(e.entityPlayer); //New item function. Just easier in once line and place.
}
else if (e.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK && e.entityPlayer.getHeldItem() != null && this.canThrow(e.entityPlayer.getHeldItem()))
{
Block block = e.world.getBlock(e.x, e.y, e.z);
if (!block.onBlockActivated(e.world, e.x, e.y, e.z, e.entityPlayer, e.face, e.x, e.y, e.z)) //Don't know what the last 3 parameters are
{
e.setResult(Result.DEFAULT);
this.throwBrickEvent(e.entityPlayer);
}
e.setCanceled(true);
}
}