类 BonemealEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.player.BonemealEvent
所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent

public class BonemealEvent extends net.neoforged.bus.api.Event implements net.neoforged.bus.api.ICancellableEvent
This event is called when a player attempts to use bone meal on a block.

This event can be cancelled, preventing vanilla handling from occurring. If you want to perform custom logic, cancel the event and perform your own handling. Use setSuccessful(boolean) to control if handling should believe bone meal was used.

This event is fired on both client and server.

  • 字段详细资料

    • player

      @Nullable private final @Nullable Player player
    • level

      private final Level level
    • pos

      private final BlockPos pos
    • state

      private final BlockState state
    • stack

      private final ItemStack stack
    • isValidBonemealTarget

      private final boolean isValidBonemealTarget
    • isSuccess

      private boolean isSuccess
  • 构造器详细资料

  • 方法详细资料

    • getPlayer

      @Nullable public @Nullable Player getPlayer()
      返回 the player who used the bone meal, if any。
      返回:
      the player who used the bone meal, if any
    • getLevel

      public Level getLevel()
      返回 the level。
      返回:
      the level
    • getPos

      public BlockPos getPos()
      返回 the position of the bone mealed block。
      返回:
      the position of the bone mealed block
    • getState

      public BlockState getState()
      返回 the state of the bone mealed block。
      返回:
      the state of the bone mealed block
    • getStack

      public ItemStack getStack()
      Returns the bone meal item stack.

      Changes to this stack will write-back to the consumer.

    • isValidBonemealTarget

      public boolean isValidBonemealTarget()
    • setSuccessful

      public void setSuccessful(boolean success)
      Cancels the event and changes the successful state.

      The state controls if handlers believe bone meal was successfully applied, and controls things like hand swings.

    • isSuccessful

      public boolean isSuccessful()
      Returns if the event is successful. Only relevant if the event ICancellableEvent.isCanceled().
      另请参阅:
    • setCanceled

      public void setCanceled(boolean canceled)
      Cancels the event, preventing vanilla handling from being applied.
      指定者:
      setCanceled 在接口中 net.neoforged.bus.api.ICancellableEvent
      另请参阅: