public class PlayerInteractEvent extends PlayerEvent
MinecraftForge.EVENT_BUS
.
See the individual documentation on each subevent for more details.Modifier and Type | Class and Description |
---|---|
static class |
PlayerInteractEvent.EntityInteract
This event is fired on both sides when the player right clicks an entity.
|
static class |
PlayerInteractEvent.EntityInteractSpecific
This event is fired on both sides whenever a player right clicks an entity.
|
static class |
PlayerInteractEvent.LeftClickBlock
This event is fired when a player left clicks while targeting a block.
|
static class |
PlayerInteractEvent.LeftClickEmpty
This event is fired on the client side when the player left clicks empty space with any ItemStack.
|
static class |
PlayerInteractEvent.RightClickBlock
This event is fired on both sides whenever the player right clicks while targeting a block.
|
static class |
PlayerInteractEvent.RightClickEmpty
This event is fired on the client side when the player right clicks empty space with an empty hand.
|
static class |
PlayerInteractEvent.RightClickItem
This event is fired on both sides before the player triggers
Item.onItemRightClick(net.minecraft.world.World, net.minecraft.entity.player.PlayerEntity, net.minecraft.util.Hand) . |
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 ActionResultType |
cancellationResult |
private Direction |
face |
private Hand |
hand |
private BlockPos |
pos |
Modifier | Constructor and Description |
---|---|
private |
PlayerInteractEvent(PlayerEntity player,
Hand hand,
BlockPos pos,
Direction face) |
Modifier and Type | Method and Description |
---|---|
ActionResultType |
getCancellationResult() |
Direction |
getFace() |
Hand |
getHand() |
ItemStack |
getItemStack() |
BlockPos |
getPos()
If the interaction was on an entity, will be a BlockPos centered on the entity.
|
LogicalSide |
getSide() |
World |
getWorld() |
void |
setCancellationResult(ActionResultType result)
Set the EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant
method of the event.
|
getPlayer
getEntityLiving
getEntity
private final Hand hand
private final BlockPos pos
@Nullable private final Direction face
private ActionResultType cancellationResult
private PlayerInteractEvent(PlayerEntity player, Hand hand, BlockPos pos, @Nullable Direction face)
@Nonnull public Hand getHand()
@Nonnull public ItemStack getItemStack()
ItemStack.EMPTY
if the hand was empty.@Nonnull public BlockPos getPos()
@Nullable public Direction getFace()
public World getWorld()
public LogicalSide getSide()
LogicalSide.CLIENT
on the client thread, and LogicalSide.SERVER
on the server thread.public ActionResultType getCancellationResult()
EnumActionResult#PASS
, meaning cancelled events will cause
the client to keep trying more interactions until something works.public void setCancellationResult(ActionResultType result)
PlayerInteractEvent.RightClickBlock
, PlayerInteractEvent.RightClickItem
, PlayerInteractEvent.EntityInteract
, and PlayerInteractEvent.EntityInteractSpecific
.