类 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.
-
字段概要
字段 -
构造器概要
构造器构造器说明BonemealEvent
(@Nullable Player player, Level level, BlockPos pos, BlockState state, ItemStack stack) -
方法概要
修饰符和类型方法说明getLevel()
返回 the level。@Nullable Player
返回 the player who used the bone meal, if any。getPos()
返回 the position of the bone mealed block。getStack()
Returns the bone meal item stack.getState()
返回 the state of the bone mealed block。boolean
Returns if the event is successful.boolean
Returns true if the block is a valid bone meal target.void
setCanceled
(boolean canceled) Cancels the event, preventing vanilla handling from being applied.void
setSuccessful
(boolean success) Cancels the event and changes the successful state.从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.bus.api.ICancellableEvent
isCanceled
-
字段详细资料
-
player
-
level
-
pos
-
state
-
stack
-
isValidBonemealTarget
private final boolean isValidBonemealTarget -
isSuccess
private boolean isSuccess
-
-
构造器详细资料
-
BonemealEvent
public BonemealEvent(@Nullable @Nullable Player player, Level level, BlockPos pos, BlockState state, ItemStack stack)
-
-
方法详细资料
-
getPlayer
返回 the player who used the bone meal, if any。- 返回:
- the player who used the bone meal, if any
-
getLevel
返回 the level。- 返回:
- the level
-
getPos
返回 the position of the bone mealed block。- 返回:
- the position of the bone mealed block
-
getState
返回 the state of the bone mealed block。- 返回:
- the state of the bone mealed block
-
getStack
Returns the bone meal item stack.Changes to this stack will write-back to the consumer.
-
isValidBonemealTarget
public boolean isValidBonemealTarget()Returns true if the block is a valid bone meal target.This is determined by
BonemealableBlock.isValidBonemealTarget(net.minecraft.world.level.LevelReader, net.minecraft.core.BlockPos, net.minecraft.world.level.block.state.BlockState)
. -
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 eventICancellableEvent.isCanceled()
.- 另请参阅:
-
setCanceled
public void setCanceled(boolean canceled) Cancels the event, preventing vanilla handling from being applied.- 指定者:
setCanceled
在接口中net.neoforged.bus.api.ICancellableEvent
- 另请参阅:
-