PaperMC/Spigot-API-Patches/Add-API-to-get-exact-interaction-point-in-PlayerInte.patch

68 lines
2.8 KiB
Diff
Raw Normal View History

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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerInteractEvent.java
@@ -0,0 +0,0 @@
package org.bukkit.event.player;
+import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
@@ -0,0 +0,0 @@ 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
@@ -0,0 +0,0 @@ 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() {