mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-04 22:14:40 +01:00
68 lines
2.8 KiB
Diff
68 lines
2.8 KiB
Diff
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||
|
From: Matthew Miller <mnmiller1@me.com>
|
||
|
Date: Mon, 4 Jan 2021 16:40:55 +1000
|
||
|
Subject: [PATCH] Add API to get exact interaction point in PlayerInteractEvent
|
||
|
|
||
|
|
||
|
diff --git a/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java b/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java
|
||
|
index 1208e1f8c2163d83c5b12bbb9b7ac044c72380e0..a01f86e6aba8b66ecc713da0787cd861e2930a2a 100644
|
||
|
--- a/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java
|
||
|
+++ b/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;
|
||
|
@@ -34,22 +35,30 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
|
||
|
private Result useClickedBlock;
|
||
|
private Result useItemInHand;
|
||
|
private EquipmentSlot hand;
|
||
|
+ private Location interactionPoint; // Paper
|
||
|
|
||
|
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace) {
|
||
|
this(who, action, item, clickedBlock, clickedFace, EquipmentSlot.HAND);
|
||
|
}
|
||
|
|
||
|
public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand) {
|
||
|
+ // Paper start - Add interactionPoint
|
||
|
+ this(who, action, item, clickedBlock, clickedFace, hand, null);
|
||
|
+ }
|
||
|
+
|
||
|
+ public PlayerInteractEvent(@NotNull final Player who, @NotNull final Action action, @Nullable final ItemStack item, @Nullable final Block clickedBlock, @NotNull final BlockFace clickedFace, @Nullable final EquipmentSlot hand, @Nullable final Location interactionPoint) {
|
||
|
super(who);
|
||
|
this.action = action;
|
||
|
this.item = item;
|
||
|
this.blockClicked = clickedBlock;
|
||
|
this.blockFace = clickedFace;
|
||
|
this.hand = hand;
|
||
|
+ this.interactionPoint = interactionPoint;
|
||
|
|
||
|
useItemInHand = Result.DEFAULT;
|
||
|
useClickedBlock = clickedBlock == null ? Result.DENY : Result.ALLOW;
|
||
|
}
|
||
|
+ // Paper end
|
||
|
|
||
|
/**
|
||
|
* Returns the action type
|
||
|
@@ -221,6 +230,18 @@ public class PlayerInteractEvent extends PlayerEvent implements Cancellable {
|
||
|
return hand;
|
||
|
}
|
||
|
|
||
|
+ // 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() {
|
||
|
+ return interactionPoint;
|
||
|
+ }
|
||
|
+ // Paper end
|
||
|
+
|
||
|
@NotNull
|
||
|
@Override
|
||
|
public HandlerList getHandlers() {
|