类 SweepAttackEvent

所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent

public class SweepAttackEvent extends PlayerEvent implements net.neoforged.bus.api.ICancellableEvent
The SweepAttackEvent is fired when a Player attacks a target, after the CriticalHitEvent has been fired.

This event can be used to force an attack to trigger a sweep, or to prevent a sweep from occurring.

This event is fired on both the logical client and logical server.

  • 字段详细资料

    • target

      private final Entity target
    • isVanillaSweep

      private final boolean isVanillaSweep
    • isSweeping

      private boolean isSweeping
  • 构造器详细资料

    • SweepAttackEvent

      public SweepAttackEvent(Player player, Entity target, boolean isVanillaSweep)
  • 方法详细资料

    • getTarget

      public Entity getTarget()
      Returns the target of the attack, which is guaranteed to be a valid attack target.
    • isVanillaSweep

      public boolean isVanillaSweep()
      Returns true if the attack would cause a sweep by utilizing the vanilla rules.

      The vanilla rules are as follows. All of them must be true for a vanilla sweep to occur:

      1. The player's attack strength is greater than 90%.
      2. The attack is not a critical hit, or is a critical hit which does not disable the sweep attack.
      3. The player is on the ground.
      4. The distance the player has traveled this tick is less than their speed.
      5. The player's weapon supports sweep attacks via ItemAbilities.SWORD_SWEEP.
    • isSweeping

      public boolean isSweeping()
      Returns true if the attack will be trigger a sweep.
    • setSweeping

      public void setSweeping(boolean sweep)
      参数:
      sweep - Whether to enable a sweep for this attack.
    • setCanceled

      public void setCanceled(boolean canceled)
      Cancels the event, preventing further event handlers from acting. Canceling the event will use the current value of isSweeping().

      If you intend to perform a custom sweep attack, you should cancel the event and setSweeping(boolean) to false before performing your handling.

      指定者:
      setCanceled 在接口中 net.neoforged.bus.api.ICancellableEvent