Possible addition to Mixin Examples External Link
static { int i = 4; }
public class ExampleMod implements ModInitializer { [...] @Override public void onInitialize() { AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> { BlockState state = world.getBlockState(pos); /* Manual spectator check is necessary because AttackBlockCallbacks fire before the spectator check */ if (state.isToolRequired() && !player.isSpectator() && player.getMainHandStack().isEmpty()) { player.damage(player.getDamageSources().generic(), 1.0F); } return ActionResult.PASS; }); } }