/**
* Callback for left-clicking ("attacking") a block.
* Is hooked in before the spectator check, so make sure to check for the player's game mode as well!
*
* Upon return:
*
- SUCCESS cancels further processing and, on the client, sends a packet to the server.
*
- PASS falls back to further processing.
*
- FAIL cancels further processing and does not send a packet to the server.
*
* ATTACK_BLOCK does not let you control the packet sending process yet.
*/
public class ExampleMod implements ModInitializer
{
[...]
@Override
public void onInitialize() {
AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> {
// Do sth...
if ([condition]) {
return ActionResult.SUCCESS;
} else {
return ActionResult.PASS;
}
})
}
}