类 BlockEvent.BlockToolModificationEvent
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.BlockEvent
net.neoforged.neoforge.event.level.BlockEvent.BlockToolModificationEvent
- 所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent
- 封闭类:
BlockEvent
public static class BlockEvent.BlockToolModificationEvent
extends BlockEvent
implements net.neoforged.bus.api.ICancellableEvent
Fired when a block is right-clicked by a tool to change its state.
For example: Used to determine if
an axe can strip
,
a shovel can path
, or a hoe can till
.
Care must be taken to ensure level-modifying events are only performed if isSimulated()
returns false
.
This event is ICancellableEvent
. If canceled, this will prevent the tool
from changing the block's state.
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.level.BlockEvent
BlockEvent.BlockToolModificationEvent, BlockEvent.BreakEvent, BlockEvent.EntityMultiPlaceEvent, BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEvent
-
字段概要
字段修饰符和类型字段说明private final UseOnContext
private final ItemAbility
private final boolean
private BlockState
-
构造器概要
构造器构造器说明BlockToolModificationEvent
(BlockState originalState, UseOnContext context, ItemAbility itemAbility, boolean simulate) -
方法概要
修饰符和类型方法说明Returns the nonnull use on context that this event was performed in.Returns the state to transform the block into after item ability use.@Nullable Player
boolean
Returnstrue
if this event should not perform any actions that modify the level.void
setFinalState
(@Nullable BlockState finalState) Sets the state to transform the block into after tool use.从类继承的方法 net.neoforged.neoforge.event.level.BlockEvent
getLevel, getPos, getState
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.bus.api.ICancellableEvent
isCanceled, setCanceled
-
字段详细资料
-
context
-
itemAbility
-
simulate
private final boolean simulate -
state
-
-
构造器详细资料
-
BlockToolModificationEvent
public BlockToolModificationEvent(BlockState originalState, UseOnContext context, ItemAbility itemAbility, boolean simulate)
-
-
方法详细资料
-
getPlayer
- 返回:
- the player using the tool.
May be null based on what was provided by
the use on context
.
-
getHeldItemStack
- 返回:
- the tool being used
-
getItemAbility
- 返回:
- the ability being performed
-
isSimulated
public boolean isSimulated()Returnstrue
if this event should not perform any actions that modify the level. Iffalse
, then level-modifying actions can be performed.- 返回:
true
if this event should not perform any actions that modify the level. Iffalse
, then level-modifying actions can be performed.
-
getContext
Returns the nonnull use on context that this event was performed in.- 返回:
- the nonnull use on context that this event was performed in
-
setFinalState
Sets the state to transform the block into after tool use.- 参数:
finalState
- the state to transform the block into after tool use- 另请参阅:
-
getFinalState
Returns the state to transform the block into after item ability use. IfsetFinalState(BlockState)
is not called, this will return the original state. IfICancellableEvent.isCanceled()
istrue
, this value will be ignored and the item ability will be canceled.- 返回:
- the state to transform the block into after tool use
-