From dfe892aa1a79a5f8ef284b557ee23e611bf392fa Mon Sep 17 00:00:00 2001 From: GreatWyrm Date: Fri, 5 Jan 2024 23:15:28 -0800 Subject: [PATCH] Update block interact event, and add some clarifying Javadocs on what blockItemUse method does (#102) --- .../event/player/PlayerBlockInteractEvent.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java index e664bbd29..2ee16cf92 100644 --- a/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java +++ b/src/main/java/net/minestom/server/event/player/PlayerBlockInteractEvent.java @@ -19,6 +19,7 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent private final Player.Hand hand; private final Block block; private final Point blockPosition; + private final Point cursorPosition; private final BlockFace blockFace; /** @@ -36,6 +37,7 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent this.hand = hand; this.block = block; this.blockPosition = blockPosition; + this.cursorPosition = cursorPosition; this.blockFace = blockFace; } @@ -48,6 +50,11 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent return blocksItemUse; } + /** + * Sets the blocking item use state of this event + * Note: If this is true, then no {@link PlayerUseItemOnBlockEvent} will be fired. + * @param blocks - true to block item interactions, false to not block + */ public void setBlockingItemUse(boolean blocks) { this.blocksItemUse = blocks; } @@ -66,6 +73,12 @@ public class PlayerBlockInteractEvent implements PlayerInstanceEvent, BlockEvent return blockPosition; } + /** + * Gets the cursor position of the interacted block + * @return the cursor position of the interaction + */ + public @NotNull Point getCursorPosition() { return cursorPosition; } + /** * Gets the hand used for the interaction. *