Class PlayerInteractEvent.RightClickBlock
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.RightClickBlock
- Enclosing class:
- PlayerInteractEvent
This event is fired on both sides whenever the player right clicks while targeting a block.
This event controls which of
Canceling the event will cause none of the above three to be called.
Let result be the first non-pass return value of the above three methods, or pass, if they all pass.
Or
If result equals
There are various results to this event, see the getters below.
Note that handling things differently on the client vs server may cause desynchronizations!
This event controls which of
IForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
, Block#onBlockActivated
, and Item#onItemUse
will be called. Canceling the event will cause none of the above three to be called.
Let result be the first non-pass return value of the above three methods, or pass, if they all pass.
Or
PlayerInteractEvent.cancellationResult
if the event is cancelled. If result equals
ActionResultType.PASS
, we proceed to 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!
-
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, PlayerEvent.Visibility
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingUpdateEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.CanUpdate, EntityEvent.EnteringChunk, 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
Modifier and TypeFieldDescriptionprivate BlockRayTraceResult
private net.minecraftforge.eventbus.api.Event.Result
private net.minecraftforge.eventbus.api.Event.Result
-
Constructor Summary
ConstructorDescriptionRightClickBlock
(PlayerEntity player, Hand hand, BlockPos pos, Direction face) Deprecated.RightClickBlock
(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec) -
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) DENY:Block#onBlockActivated
will never be called.void
setUseItem
(net.minecraftforge.eventbus.api.Event.Result triggerItem) DENY: NeitherItem#onItemUse
orIForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
will be called.Methods inherited from class net.minecraftforge.event.entity.player.PlayerInteractEvent
getCancellationResult, getFace, getHand, getItemStack, getPos, getSide, getWorld, setCancellationResult
Methods inherited from class net.minecraftforge.event.entity.player.PlayerEvent
getPlayer
Methods inherited from class net.minecraftforge.event.entity.living.LivingEvent
getEntityLiving
Methods inherited from class net.minecraftforge.event.entity.EntityEvent
getEntity
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getParentListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult, setup
-
Field Details
-
useBlock
private net.minecraftforge.eventbus.api.Event.Result useBlock -
useItem
private net.minecraftforge.eventbus.api.Event.Result useItem -
hitVec
-
-
Constructor Details
-
RightClickBlock
Deprecated. -
RightClickBlock
-
-
Method Details
-
getUseBlock
public net.minecraftforge.eventbus.api.Event.Result getUseBlock()- Returns:
- If
net.minecraft.block.Block#onBlockActivated
should be called
-
getUseItem
public net.minecraftforge.eventbus.api.Event.Result getUseItem()- Returns:
- If
IForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
andnet.minecraft.item.Item#onItemUse
should be called
-
getHitVec
- Returns:
- The ray trace result targeting the block.
-
setUseBlock
public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock) DENY:Block#onBlockActivated
will never be called.
DEFAULT:Block#onBlockActivated
will be called ifIForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
passes.
Note that default activation can be blocked if the user is sneaking and holding an item that does not return true toIForgeItem.doesSneakBypassUse(net.minecraft.item.ItemStack, net.minecraft.world.IWorldReader, net.minecraft.util.math.BlockPos, net.minecraft.entity.player.PlayerEntity)
.
ALLOW:Block#onBlockActivated
will always be called, unlessIForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
does not pass. -
setUseItem
public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem) DENY: NeitherItem#onItemUse
orIForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
will be called.
DEFAULT:IForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
will always be called, andItem#onItemUse
will be called if the block passes.
ALLOW:IForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
will always be called, andItem#onItemUse
will be called if the block passes, regardless of cooldowns or emptiness. -
setCanceled
public void setCanceled(boolean canceled) - Overrides:
setCanceled
in classnet.minecraftforge.eventbus.api.Event
-