Class PlayerInteractEvent

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

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

    • hand

      private final net.minecraft.world.InteractionHand hand
    • pos

      private final net.minecraft.core.BlockPos pos
    • face

      @Nullable private final @Nullable net.minecraft.core.Direction face
  • Constructor Details

    • PlayerInteractEvent

      protected PlayerInteractEvent(net.minecraft.world.entity.player.Player player, net.minecraft.world.InteractionHand hand, net.minecraft.core.BlockPos pos, @Nullable @Nullable net.minecraft.core.Direction face)
  • Method Details

    • getHand

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

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

      public net.minecraft.core.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 net.minecraft.core.Direction getFace()
      Returns:
      The face involved in this interaction. For all non-block interactions, this will return null.
    • getLevel

      public net.minecraft.world.level.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.