类 PlayerInteractEvent.RightClickBlock
java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.entity.EntityEvent
net.neoforged.neoforge.event.entity.living.LivingEvent
net.neoforged.neoforge.event.entity.player.PlayerEvent
net.neoforged.neoforge.event.entity.player.PlayerInteractEvent
net.neoforged.neoforge.event.entity.player.PlayerInteractEvent.RightClickBlock
- 所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent
- 封闭类:
PlayerInteractEvent
public static class PlayerInteractEvent.RightClickBlock
extends PlayerInteractEvent
implements net.neoforged.bus.api.ICancellableEvent
This event is fired on both sides whenever the player right clicks while targeting a block.
This event controls which of
,
and
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
IItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
,
引用无效
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
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
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!
-
嵌套类概要
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.player.PlayerInteractEvent
PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItem
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.player.PlayerEvent
PlayerEvent.BreakSpeed, PlayerEvent.Clone, PlayerEvent.HarvestCheck, PlayerEvent.ItemCraftedEvent, PlayerEvent.ItemSmeltedEvent, PlayerEvent.LoadFromFile, PlayerEvent.NameFormat, PlayerEvent.PlayerChangedDimensionEvent, PlayerEvent.PlayerChangeGameModeEvent, PlayerEvent.PlayerLoggedInEvent, PlayerEvent.PlayerLoggedOutEvent, PlayerEvent.PlayerRespawnEvent, PlayerEvent.SaveToFile, PlayerEvent.StartTracking, PlayerEvent.StopTracking, PlayerEvent.TabListNameFormat
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.living.LivingEvent
LivingEvent.LivingJumpEvent, LivingEvent.LivingVisibilityEvent
从类继承的嵌套类/接口 net.neoforged.neoforge.event.entity.EntityEvent
EntityEvent.EnteringSection, EntityEvent.EntityConstructing, EntityEvent.Size
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明void
setCanceled
(boolean canceled) void
Set the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.void
setUseBlock
(TriState triggerBlock) FALSE:引用无效
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
void
setUseItem
(TriState triggerItem) FALSE: NeitherItem.useOn(UseOnContext)
orIItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will be called.从类继承的方法 net.neoforged.neoforge.event.entity.player.PlayerInteractEvent
getFace, getHand, getItemStack, getLevel, getPos, getSide
从类继承的方法 net.neoforged.neoforge.event.entity.player.PlayerEvent
getEntity
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
从接口继承的方法 net.neoforged.bus.api.ICancellableEvent
isCanceled
-
字段详细资料
-
cancellationResult
-
useBlock
-
useItem
-
hitVec
-
-
构造器详细资料
-
RightClickBlock
-
-
方法详细资料
-
getUseBlock
- 返回:
- If
引用无效
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
-
getUseItem
-
getHitVec
- 返回:
- The ray trace result targeting the block.
-
setUseBlock
FALSE:引用无效
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
DEFAULT:引用无效
Block#use(BlockState, Level, BlockPos, Player, InteractionHand, BlockHitResult)
IItemExtension.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 toIItemExtension.doesSneakBypassUse(net.minecraft.world.item.ItemStack, net.minecraft.world.level.LevelReader, net.minecraft.core.BlockPos, net.minecraft.world.entity.player.Player)
.
TRUE:Block.updateOrDestroy(BlockState, BlockState, LevelAccessor, BlockPos, int, int)
will always be called, unlessIItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
does not pass. -
setUseItem
FALSE: NeitherItem.useOn(UseOnContext)
orIItemExtension.onItemUseFirst(net.minecraft.world.item.ItemStack, net.minecraft.world.item.context.UseOnContext)
will be called.
DEFAULT:IItemExtension.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.
TRUE:IItemExtension.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) - 指定者:
setCanceled
在接口中net.neoforged.bus.api.ICancellableEvent
-
getCancellationResult
- 返回:
- The InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
method of the event. By default, this is
InteractionResult.PASS
, meaning cancelled events will cause the client to keep trying more interactions until something works.
-
setCancellationResult
Set the InteractionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event.
-