attackBlock

open fun attackBlock(staffStack: ItemStack, world: World, attacker: LivingEntity, target: BlockPos, side: Direction, hand: Hand): ActionResult(source)

Called on both the client and the server by Fabric API, when an entity attacks a block.

On the logical client, the return values have the following meaning:

  • SUCCESS: Cancel vanilla block breaking, send a packet to the server, spawn block breaking particles, and swing hand. This doesn't reset the block breaking cooldown

  • CONSUME, CONSUME_PARTIAL: Cancel vanilla block breaking, send a packet to the server, don't spawn block breaking particles, and don't swing hand. This doesn't reset the block breaking cooldown

  • PASS: Let Minecraft handle vanilla block breaking

  • FAIL: Cancel vanilla block breaking, don't send a packet to the server, don't spawn block breaking particles, and don't swing hand. This doesn't reset the block breaking cooldown

On the logical server, the return values have the following meaning (if used by player):

  • SUCCESS, CONSUME, CONSUME_PARTIAL, FAIL: Cancel vanilla block breaking, and notify the client

  • PASS: Let Minecraft handle vanilla block breaking

On the logical server, the return values are processed by the caller code (if the attacker is not a player).

Parameters

staffStack

The item stack used to perform the action

world

The world the attacker is in

attacker

The entity, which attacked with the staff

target

The block the attacker attacked

side

The side of the block, which was attacked

hand

The hand of the attacker, in which the staff is

See also