public static class PlayerInteractEvent.RightClickBlock extends PlayerInteractEvent
Block.onBlockActivated(net.minecraft.block.BlockState, net.minecraft.world.World, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.PlayerEntity, net.minecraft.util.Hand, net.minecraft.util.math.BlockRayTraceResult)
and/or Item.onItemUse(net.minecraft.item.ItemUseContext)
will be called after IForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
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.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 |
---|
RightClickBlock(PlayerEntity player,
Hand hand,
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)
DENY: Block will never be used.
|
void |
setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem)
DENY: The item will never be used.
|
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 RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face)
public net.minecraftforge.eventbus.api.Event.Result getUseBlock()
public net.minecraftforge.eventbus.api.Event.Result getUseItem()
public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock)
IForgeItem.doesSneakBypassUse(net.minecraft.item.ItemStack, net.minecraft.world.IWorldReader, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.PlayerEntity)
).
ALLOW: Block will always be used, regardless of sneaking and doesSneakBypassUse.public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem)
public void setCanceled(boolean canceled)
setCanceled
in class net.minecraftforge.eventbus.api.Event