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
public static class PlayerInteractEvent.RightClickBlock extends PlayerInteractEvent
This event is fired on both sides whenever the player right clicks while targeting a block.
This event controls which ofIForgeItem.onItemUseFirst(net.minecraft.item.ItemStack, net.minecraft.item.ItemUseContext)
,Block#onBlockActivated
, andItem#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.
OrPlayerInteractEvent.cancellationResult
if the event is cancelled.
If result equalsActionResultType.PASS
, we proceed toPlayerInteractEvent.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
-
-
Field Summary
Fields Modifier and Type Field Description private BlockRayTraceResult
hitVec
private net.minecraftforge.eventbus.api.Event.Result
useBlock
private net.minecraftforge.eventbus.api.Event.Result
useItem
-
Constructor Summary
Constructors Constructor Description RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face)
Deprecated.RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BlockRayTraceResult
getHitVec()
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#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
-
-
-
-
Field Detail
-
useBlock
private net.minecraftforge.eventbus.api.Event.Result useBlock
-
useItem
private net.minecraftforge.eventbus.api.Event.Result useItem
-
hitVec
private BlockRayTraceResult hitVec
-
-
Constructor Detail
-
RightClickBlock
@Deprecated public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, Direction face)
Deprecated.
-
RightClickBlock
public RightClickBlock(PlayerEntity player, Hand hand, BlockPos pos, BlockRayTraceResult hitVec)
-
-
Method Detail
-
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
public BlockRayTraceResult 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
-
-