public static class PlayerInteractEvent.LeftClickBlock extends PlayerInteractEvent
Block.onBlockClicked(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.PlayerEntity)
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.PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItem
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemPickupEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.Visibility
LivingEvent.LivingJumpEvent, LivingEvent.LivingUpdateEvent
EntityEvent.CanUpdate, EntityEvent.EnteringChunk, EntityEvent.EntityConstructing, EntityEvent.EyeHeight
Modifier and Type | Field and Description |
---|---|
private net.minecraftforge.eventbus.api.Event.Result |
useBlock |
private net.minecraftforge.eventbus.api.Event.Result |
useItem |
Constructor and Description |
---|
LeftClickBlock(PlayerEntity player,
BlockPos pos,
Direction face) |
Modifier and Type | Method and Description |
---|---|
net.minecraftforge.eventbus.api.Event.Result |
getUseBlock() |
net.minecraftforge.eventbus.api.Event.Result |
getUseItem() |
void |
setCanceled(boolean canceled) |
void |
setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock) |
void |
setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem) |
getCancellationResult, getFace, getHand, getItemStack, getPos, getSide, getWorld, setCancellationResult
getPlayer
getEntityLiving
getEntity
private net.minecraftforge.eventbus.api.Event.Result useBlock
private net.minecraftforge.eventbus.api.Event.Result useItem
public LeftClickBlock(PlayerEntity player, BlockPos pos, Direction face)
public net.minecraftforge.eventbus.api.Event.Result getUseBlock()
Block.onBlockClicked(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.PlayerEntity)
should be called. Changing this has no effect in creative modepublic net.minecraftforge.eventbus.api.Event.Result getUseItem()
public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock)
public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem)
public void setCanceled(boolean canceled)
setCanceled
in class net.minecraftforge.eventbus.api.Event