Class PlayerInteractEvent

Direct Known Subclasses:
PlayerInteractEvent.EntityInteract, PlayerInteractEvent.EntityInteractSpecific, PlayerInteractEvent.LeftClickBlock, PlayerInteractEvent.LeftClickEmpty, PlayerInteractEvent.RightClickBlock, PlayerInteractEvent.RightClickEmpty, PlayerInteractEvent.RightClickItem, UseItemOnBlockEvent

public abstract class PlayerInteractEvent extends PlayerEvent
PlayerInteractEvent is fired when a player interacts in some way. All subclasses are fired on NeoForge.EVENT_BUS. See the individual documentation on each subevent for more details.
  • Field Details

  • Constructor Details

  • Method Details

    • getHand

      public InteractionHand getHand()
      Returns:
      The hand involved in this interaction. Will never be null.
    • getItemStack

      public ItemStack getItemStack()
      Returns:
      The itemstack involved in this interaction, ItemStack.EMPTY if the hand was empty.
    • getPos

      public BlockPos getPos()
      If the interaction was on an entity, will be a BlockPos centered on the entity. If the interaction was on a block, will be the position of that block. Otherwise, will be a BlockPos centered on the player. Will never be null.
      Returns:
      The position involved in this interaction.
    • getFace

      @Nullable public @Nullable Direction getFace()
      Returns:
      The face involved in this interaction. For all non-block interactions, this will return null.
    • getLevel

      public Level getLevel()
      Returns:
      Convenience method to get the level of this interaction.
    • getSide

      public net.neoforged.fml.LogicalSide getSide()
      Returns:
      The effective, i.e. logical, side of this interaction. This will be LogicalSide.CLIENT on the client thread, and LogicalSide.SERVER on the server thread.