public static class PlayerInteractEvent.LeftClickBlock extends PlayerInteractEvent
Block.onBlockClicked(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.EntityPlayer)
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.fml.common.eventhandler.Event.Result)
and setUseItem(net.minecraftforge.fml.common.eventhandler.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.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.Visibility
LivingEvent.LivingJumpEvent, LivingEvent.LivingUpdateEvent
EntityEvent.CanUpdate, EntityEvent.EnteringChunk, EntityEvent.EntityConstructing
Event.HasResult, Event.Result
Constructor and Description |
---|
LeftClickBlock(EntityPlayer player,
BlockPos pos,
EnumFacing face,
Vec3d hitVec) |
Modifier and Type | Method and Description |
---|---|
Vec3d |
getHitVec() |
Event.Result |
getUseBlock() |
Event.Result |
getUseItem() |
void |
setCanceled(boolean canceled)
Sets the cancel state of this event.
|
void |
setUseBlock(Event.Result triggerBlock) |
void |
setUseItem(Event.Result triggerItem) |
getCancellationResult, getFace, getHand, getItemStack, getPos, getSide, getWorld, setCancellationResult
getEntityPlayer
getEntityLiving
getEntity
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult, setup
public LeftClickBlock(EntityPlayer player, BlockPos pos, EnumFacing face, Vec3d hitVec)
public Vec3d getHitVec()
public Event.Result getUseBlock()
Block.onBlockClicked(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.EntityPlayer)
should be called. Changing this has no effect in creative modepublic Event.Result getUseItem()
public void setUseBlock(Event.Result triggerBlock)
public void setUseItem(Event.Result triggerItem)
public void setCanceled(boolean canceled)
Event
Event.isCancelable()
will result in an UnsupportedOperationException
.
The functionality of setting the canceled state is defined on a per-event bases.setCanceled
in class Event
canceled
- The new canceled value