Interface HitBoxListener


public interface HitBoxListener
Listens for events related to a HitBox, such as damage, interaction, and mounting.

This interface allows for custom behavior when a hitbox is interacted with.

Since:
1.15.2
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Builder for HitBoxListener.
    static interface 
    Functional interface for handling damage events.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HitBoxListener
    An empty listener that does nothing.
  • Method Summary

    Modifier and Type
    Method
    Description
    static @NotNull HitBoxListener.Builder
    Creates a new builder for HitBoxListener.
    boolean
    damage(@NotNull HitBox hitBox, @NotNull ModelDamageSource source, double damage)
    Called when the hitbox receives damage.
    void
    dismount(@NotNull HitBox hitBox, @NotNull org.bukkit.entity.Entity entity)
    Called when an entity dismounts the hitbox.
    void
    mount(@NotNull HitBox hitBox, @NotNull org.bukkit.entity.Entity entity)
    Called when an entity mounts the hitbox.
    void
    remove(@NotNull HitBox hitBox)
    Called when the hitbox is removed.
    void
    sync(@NotNull HitBox hitBox)
    Called when the hitbox is synchronized (ticked).
    default @NotNull HitBoxListener.Builder
    Creates a builder initialized with this listener's current handlers.
  • Field Details

    • EMPTY

      static final HitBoxListener EMPTY
      An empty listener that does nothing.
      Since:
      1.15.2
  • Method Details

    • builder

      @NotNull static @NotNull HitBoxListener.Builder builder()
      Creates a new builder for HitBoxListener.
      Returns:
      a new builder
      Since:
      1.15.2
    • toBuilder

      @NotNull default @NotNull HitBoxListener.Builder toBuilder()
      Creates a builder initialized with this listener's current handlers.
      Returns:
      a new builder
      Since:
      1.15.2
    • sync

      void sync(@NotNull @NotNull HitBox hitBox)
      Called when the hitbox is synchronized (ticked).
      Parameters:
      hitBox - the target hitbox
      Since:
      1.15.2
    • damage

      boolean damage(@NotNull @NotNull HitBox hitBox, @NotNull @NotNull ModelDamageSource source, double damage)
      Called when the hitbox receives damage.
      Parameters:
      hitBox - the target hitbox
      source - the damage source
      damage - the damage amount
      Returns:
      true if the damage was cancelled
      Since:
      1.15.2
    • remove

      void remove(@NotNull @NotNull HitBox hitBox)
      Called when the hitbox is removed.
      Parameters:
      hitBox - the target hitbox
      Since:
      1.15.2
    • mount

      void mount(@NotNull @NotNull HitBox hitBox, @NotNull @NotNull org.bukkit.entity.Entity entity)
      Called when an entity mounts the hitbox.
      Parameters:
      hitBox - the target hitbox
      entity - the mounting entity
      Since:
      1.15.2
    • dismount

      void dismount(@NotNull @NotNull HitBox hitBox, @NotNull @NotNull org.bukkit.entity.Entity entity)
      Called when an entity dismounts the hitbox.
      Parameters:
      hitBox - the target hitbox
      entity - the dismounting entity
      Since:
      1.15.2