attackEntity

open fun attackEntity(staffStack: ItemStack, world: World, attacker: LivingEntity, target: Entity, hand: Hand): ActionResult(source)

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

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

  • SUCCESS: Cancel vanilla entity attack, send a packet to the server, and swing hand. This doesn't reset the entity attack cooldown

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

  • PASS: Let Minecraft handle vanilla entity attack

  • FAIL: Cancel vanilla entity attack, don't send a packet to the server, and don't swing hand. This doesn't reset the entity attack cooldown

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

  • SUCCESS, CONSUME, CONSUME_PARTIAL, FAIL: Cancel vanilla entity attack, don't attack the entity

  • PASS: Let Minecraft handle vanilla entity attack

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 entity the attacker attacked

hand

The hand of the attacker, in which the staff is

See also