Class PlayerInteractEvent.LeftClickBlock
java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.entity.EntityEvent
net.minecraftforge.event.entity.living.LivingEvent
net.minecraftforge.event.entity.player.PlayerEvent
net.minecraftforge.event.entity.player.PlayerInteractEvent
net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock
- Enclosing class:
- PlayerInteractEvent
This event is fired when a player left clicks while targeting a block.
This event controls which of
BlockBehaviour.attack(BlockState, Level, BlockPos, Player)
and/or the item harvesting methods will be called
Canceling the event will cause none of the above noted methods to be called.
There are various results to this event, see the getters below.
Note that if the event is canceled and the player holds down left mouse, the event will continue to fire.
This is due to how vanilla calls the left click handler methods.
Also note that creative mode directly breaks the block without running any other logic.
Therefore, in creative mode, setUseBlock(net.minecraftforge.eventbus.api.Event.Result)
and setUseItem(net.minecraftforge.eventbus.api.Event.Result)
have no effect.-
Nested Class Summary
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.player.PlayerInteractEvent
PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItem
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemPickupEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingTickEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionnet.minecraftforge.eventbus.api.Event.Result
net.minecraftforge.eventbus.api.Event.Result
void
setCanceled
(boolean canceled) void
setUseBlock
(net.minecraftforge.eventbus.api.Event.Result triggerBlock) void
setUseItem
(net.minecraftforge.eventbus.api.Event.Result triggerItem) Methods inherited from class net.minecraftforge.event.entity.player.PlayerInteractEvent
getCancellationResult, getFace, getHand, getItemStack, getLevel, getPos, getSide, setCancellationResult
Methods inherited from class net.minecraftforge.event.entity.player.PlayerEvent
getEntity
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult
-
Field Details
-
useBlock
private net.minecraftforge.eventbus.api.Event.Result useBlock -
useItem
private net.minecraftforge.eventbus.api.Event.Result useItem
-
-
Constructor Details
-
LeftClickBlock
-
-
Method Details
-
getUseBlock
public net.minecraftforge.eventbus.api.Event.Result getUseBlock()- Returns:
- If
BlockBehaviour.attack(BlockState, Level, BlockPos, Player)
should be called. Changing this has no effect in creative mode
-
getUseItem
public net.minecraftforge.eventbus.api.Event.Result getUseItem()- Returns:
- If the block should be attempted to be mined with the current item. Changing this has no effect in creative mode
-
setUseBlock
public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock) -
setUseItem
public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem) -
setCanceled
public void setCanceled(boolean canceled) - Overrides:
setCanceled
in classnet.minecraftforge.eventbus.api.Event
-