Package net.minecraftforge.event.level
Class BlockEvent.BlockToolModificationEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.level.BlockEvent
net.minecraftforge.event.level.BlockEvent.BlockToolModificationEvent
- Enclosing class:
- BlockEvent
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 Cancelable. If canceled, this will prevent the tool
 from changing the block's state.
- 
Nested Class SummaryNested classes/interfaces inherited from class net.minecraftforge.event.level.BlockEventBlockEvent.BlockToolModificationEvent, BlockEvent.BreakEvent, BlockEvent.CreateFluidSourceEvent, BlockEvent.CropGrowEvent, BlockEvent.EntityMultiPlaceEvent, BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEventNested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Eventnet.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprivate final UseOnContextprivate final booleanprivate BlockStateprivate final ToolAction
- 
Constructor SummaryConstructorsConstructorDescriptionBlockToolModificationEvent(BlockState originalState, @NotNull UseOnContext context, ToolAction toolAction, boolean simulate) 
- 
Method SummaryModifier and TypeMethodDescription@NotNull UseOnContextReturns the nonnull use on context that this event was performed in.Returns the state to transform the block into after tool use.@Nullable PlayerbooleanReturnstrueif this event should not perform any actions that modify the level.voidsetFinalState(@Nullable BlockState finalState) Sets the state to transform the block into after tool use.Methods inherited from class net.minecraftforge.event.level.BlockEventgetLevel, getPos, getStateMethods inherited from class net.minecraftforge.eventbus.api.EventgetListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult
- 
Field Details- 
context
- 
toolAction
- 
simulateprivate final boolean simulate
- 
state
 
- 
- 
Constructor Details- 
BlockToolModificationEventpublic BlockToolModificationEvent(BlockState originalState, @NotNull @NotNull UseOnContext context, ToolAction toolAction, boolean simulate) 
 
- 
- 
Method Details- 
getPlayer- Returns:
- the player using the tool.
 May be null based on what was provided by the use on context.
 
- 
getHeldItemStack- Returns:
- the tool being used
 
- 
getToolAction- Returns:
- the action being performed
 
- 
isSimulatedpublic boolean isSimulated()Returnstrueif this event should not perform any actions that modify the level. Iffalse, then level-modifying actions can be performed.- Returns:
- trueif this event should not perform any actions that modify the level. If- false, then level-modifying actions can be performed.
 
- 
getContextReturns the nonnull use on context that this event was performed in.- Returns:
- the nonnull use on context that this event was performed in
 
- 
setFinalStateSets the state to transform the block into after tool use.- Parameters:
- finalState- the state to transform the block into after tool use
- See Also:
 
- 
getFinalStateReturns the state to transform the block into after tool use. IfsetFinalState(BlockState)is not called, this will return the original state. IfEvent.isCanceled()istrue, this value will be ignored and the tool action will be canceled.- Returns:
- the state to transform the block into after tool use
 
 
-