From f3d8fe46e3e15ea9f48a41b2dae14fead9f6b763 Mon Sep 17 00:00:00 2001 From: Madeline Miller Date: Mon, 4 Jan 2021 16:40:55 +1000 Subject: [PATCH] Add API to get exact interaction point in PlayerInteractEvent --- .../event/player/PlayerInteractEvent.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java index 35e0df9fc0..69c800d367 100644 --- a/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java +++ b/paper-api/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.player; +import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -234,13 +235,30 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable { *

* All vector components are between 0.0 and 1.0 inclusive. * + * @deprecated misleading, use {@link #getInteractionPoint()} * @return the clicked position. May be null. */ @Nullable + @Deprecated // Paper public Vector getClickedPosition() { return clickedPosistion; } + // Paper start + /** + * The exact point at which the interaction occurred. May be null. + * + * @return the exact interaction point. May be null. + */ + @Nullable + public Location getInteractionPoint() { + if (this.blockClicked == null || this.clickedPosistion == null) { + return null; + } + return this.blockClicked.getLocation().add(this.clickedPosistion); + } + // Paper end + @NotNull @Override public HandlerList getHandlers() {