Class PlayerInteractEvent

    • Method Detail

      • getHand

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

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

        @Nonnull
        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 Direction getFace()
        Returns:
        The face involved in this interaction. For all non-block interactions, this will return null.
      • getWorld

        public World getWorld()
        Returns:
        Convenience method to get the world of this interaction.
      • getCancellationResult

        public ActionResultType getCancellationResult()
        Returns:
        The EnumActionResult that will be returned to vanilla if the event is cancelled, instead of calling the relevant method of the event. By default, this is EnumActionResult#PASS, meaning cancelled events will cause the client to keep trying more interactions until something works.