Interface PlayerEvent.AttackEntity

Enclosing interface:
PlayerEvent

public static interface PlayerEvent.AttackEntity
  • Method Summary

    Modifier and Type
    Method
    Description
    attack(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.world.entity.Entity target, net.minecraft.world.InteractionHand hand, @Nullable net.minecraft.world.phys.EntityHitResult result)
    Invoked when a player is about to attack an entity using left-click.
  • Method Details

    • attack

      EventResult attack(net.minecraft.world.entity.player.Player player, net.minecraft.world.level.Level level, net.minecraft.world.entity.Entity target, net.minecraft.world.InteractionHand hand, @Nullable @Nullable net.minecraft.world.phys.EntityHitResult result)
      Invoked when a player is about to attack an entity using left-click. Equivalent to Forge's AttackEntityEvent and Fabric API's AttackEntityCallback events.
      Parameters:
      player - The player attacking the entity.
      level - The level the player is in.
      target - The entity about to be attacked.
      hand - The hand the player is using.
      result - The entity hit result.
      Returns:
      An EventResult determining the outcome of the event, the attack may be cancelled by the result.