public static class PlayerInteractEvent.RightClickBlock extends PlayerInteractEvent
Block.onBlockActivated(net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.block.state.IBlockState, net.minecraft.entity.player.EntityPlayer, net.minecraft.util.EnumHand, net.minecraft.util.EnumFacing, float, float, float)
and/or Item.onItemUse(net.minecraft.entity.player.EntityPlayer, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.EnumHand, net.minecraft.util.EnumFacing, float, float, float)
will be called after Item.onItemUseFirst(net.minecraft.entity.player.EntityPlayer, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.util.EnumFacing, float, float, float, net.minecraft.util.EnumHand)
is called.
Canceling the event will cause none of the above three to be called
Let result be a return value of the above three methods, or PlayerInteractEvent.cancellationResult
if the event is cancelled.
If we are on the client and result is not EnumActionResult.SUCCESS
, the client will then try PlayerInteractEvent.RightClickItem
.
There are various results to this event, see the getters below.
Note that handling things differently on the client vs server may cause desynchronizations!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 |
---|
RightClickBlock(EntityPlayer player,
EnumHand hand,
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)
DENY: Block will never be used.
|
void |
setUseItem(Event.Result triggerItem)
DENY: The item will never be used.
|
getCancellationResult, getFace, getHand, getItemStack, getPos, getSide, getWorld, setCancellationResult
getEntityPlayer
getEntityLiving
getEntity
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult, setup
public RightClickBlock(EntityPlayer player, EnumHand hand, BlockPos pos, EnumFacing face, Vec3d hitVec)
public Vec3d getHitVec()
public Event.Result getUseBlock()
public Event.Result getUseItem()
public void setUseBlock(Event.Result triggerBlock)
Item.doesSneakBypassUse(net.minecraft.item.ItemStack, net.minecraft.world.IBlockAccess, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.EntityPlayer)
).
ALLOW: Block will always be used, regardless of sneaking and doesSneakBypassUse.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