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.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
, BlockBehaviour.use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
,
and Item.useOn(UseOnContext)
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
InteractionResult.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
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingTickEvent, LivingEvent.LivingVisibilityEvent
Nested classes/interfaces inherited from class net.minecraftforge.event.entity.EntityEvent
EntityEvent.EnteringSection, 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 BlockHitResult
private net.minecraftforge.eventbus.api.Event.Result
private net.minecraftforge.eventbus.api.Event.Result
-
Constructor Summary
ConstructorDescriptionRightClickBlock
(Player player, InteractionHand hand, BlockPos pos, BlockHitResult 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:BlockBehaviour.use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
will never be called.void
setUseItem
(net.minecraftforge.eventbus.api.Event.Result triggerItem) DENY: NeitherItem.useOn(UseOnContext)
orIForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will be called.Methods inherited from class net.minecraftforge.event.entity.player.PlayerInteractEvent
getCancellationResult, getFace, getHand, getItemStack, getLevel, getPos, getSide, setCancellationResult
Methods inherited from class net.minecraftforge.event.entity.player.PlayerEvent
getEntity
Methods inherited from class net.minecraftforge.eventbus.api.Event
getListenerList, getPhase, getResult, hasResult, isCancelable, isCanceled, setPhase, setResult
-
Field Details
-
useBlock
private net.minecraftforge.eventbus.api.Event.Result useBlock -
useItem
private net.minecraftforge.eventbus.api.Event.Result useItem -
hitVec
-
-
Constructor Details
-
RightClickBlock
-
-
Method Details
-
getUseBlock
public net.minecraftforge.eventbus.api.Event.Result getUseBlock()- Returns:
- If
BlockBehaviour.use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
should be called
-
getUseItem
public net.minecraftforge.eventbus.api.Event.Result getUseItem()- Returns:
- If
IForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
andItem.useOn(UseOnContext)
should be called
-
getHitVec
- Returns:
- The ray trace result targeting the block.
-
setUseBlock
public void setUseBlock(net.minecraftforge.eventbus.api.Event.Result triggerBlock) DENY:BlockBehaviour.use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
will never be called.
DEFAULT:BlockBehaviour.use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
will be called ifIForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
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.world.item.ItemStack, net.minecraft.world.level.LevelReader, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player)
.
ALLOW:Block.updateOrDestroy(BlockState, BlockState, LevelAccessor, BlockPos, int, int)
will always be called, unlessIForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
does not pass. -
setUseItem
public void setUseItem(net.minecraftforge.eventbus.api.Event.Result triggerItem) DENY: NeitherItem.useOn(UseOnContext)
orIForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will be called.
DEFAULT:IForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will always be called, andItem.useOn(UseOnContext)
will be called if the block passes.
ALLOW:IForgeItem.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will always be called, andItem.useOn(UseOnContext)
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
-