// the event was cancelled, get out of here
revert = true;
} else {
// emit damage event - cancel by default if holding a sword
boolean instaBreak = player.getGameMode() == GameMode.CREATIVE;
BlockDamageEvent damageEvent = new BlockDamageEvent(player, block, player.getItemInHand(), instaBreak);
if (player.getGameMode() == GameMode.CREATIVE && holding != null && EnchantmentTarget.WEAPON.includes(holding.getType())) {
damageEvent.setCancelled(true);
}
EventFactory.callEvent(damageEvent);
// follow orders
if (damageEvent.isCancelled()) {
revert = true;
} else {
// in creative, break even if denied in the event, or the block
// can never be broken (client does not send DONE_DIGGING).
blockBroken = damageEvent.getInstaBreak() || instaBreak;
}
}
} else if (message.getState() == DiggingMessage.FINISH_DIGGING) {
// shouldn't happen in creative mode