Package net.minecraftforge.event.world
Class BlockEvent.BlockToolInteractEvent
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.world.BlockEvent
net.minecraftforge.event.world.BlockEvent.BlockToolInteractEvent
- Enclosing class:
- BlockEvent
Fired when when this block is right clicked by a tool to change its state.
For example: Used to determine if an axe can strip or a shovel can path.
For hoes, see
net.minecraft.world.item.HoeItem#TILLABLES
and
UseHoeEvent
.
This event is Cancelable
. If canceled, this will prevent the tool
from changing the block's state.-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.event.world.BlockEvent
BlockEvent.BlockToolInteractEvent, BlockEvent.BreakEvent, BlockEvent.CreateFluidSourceEvent, BlockEvent.CropGrowEvent, BlockEvent.EntityMultiPlaceEvent, BlockEvent.EntityPlaceEvent, BlockEvent.FarmlandTrampleEvent, BlockEvent.FluidPlaceBlockEvent, BlockEvent.NeighborNotifyEvent, BlockEvent.PortalSpawnEvent
Nested classes/interfaces inherited from class net.minecraftforge.eventbus.api.Event
net.minecraftforge.eventbus.api.Event.HasResult, net.minecraftforge.eventbus.api.Event.Result
-
Field Summary
Modifier and TypeFieldDescriptionprivate Player
private ItemStack
private BlockState
private ToolAction
-
Constructor Summary
ConstructorDescriptionBlockToolInteractEvent(LevelAccessor world, BlockPos pos, BlockState originalState, Player player, ItemStack stack, ToolAction toolAction)
-
Method Summary
Modifier and TypeMethodDescriptionGets the transformed state after tool use.Gets the tool being used.Gets the player using the tool.Gets the action being performed.void
setFinalState(BlockState finalState)
Sets the transformed state after tool use.Methods inherited from class net.minecraftforge.event.world.BlockEvent
getPos, getState, getWorld
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getParentListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setCanceled, setPhase, setResult, setup
-
Field Details
-
player
-
stack
-
toolAction
-
state
-
-
Constructor Details
-
BlockToolInteractEvent
public BlockToolInteractEvent(LevelAccessor world, BlockPos pos, BlockState originalState, Player player, ItemStack stack, ToolAction toolAction)
-
-
Method Details
-
getPlayer
Gets the player using the tool. -
getHeldItemStack
Gets the tool being used. -
getToolAction
Gets the action being performed. -
setFinalState
Sets the transformed state after tool use. If not set, will return the original state. This will be bypassed if canceled returning null instead. -
getFinalState
Gets the transformed state after tool use. If setFinalState not called, will return the original state. This will be bypassed if canceled returning null instead.
-