2021-01-08 06:26:51 +01:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Matthew Miller <mnmiller1@me.com>
|
|
|
|
Date: Mon, 4 Jan 2021 16:40:27 +1000
|
|
|
|
Subject: [PATCH] Implement API to expose exact interaction point
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
|
|
index 86d1a7625bb3016093ee8a46f91fd657d8bc2546..6ac3cf976205ea939e2a124bf9699e650eafe79f 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/level/PlayerInteractManager.java
|
|
|
|
@@ -492,7 +492,7 @@ public class PlayerInteractManager {
|
2021-01-08 06:26:51 +01:00
|
|
|
cancelledBlock = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand);
|
|
|
|
+ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, blockposition, movingobjectpositionblock.getDirection(), itemstack, cancelledBlock, enumhand, movingobjectpositionblock.getPos()); // Paper
|
|
|
|
firedInteract = true;
|
|
|
|
interactResult = event.useItemInHand() == Event.Result.DENY;
|
|
|
|
interactPosition = blockposition.immutableCopy();
|
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-16 08:19:45 +01:00
|
|
|
index 618a18fc8f3ce07f8e12bf3dd83afe5d626e8161..013ef80b91c03bb6baf6249d8584ba1a393b0dec 100644
|
2021-01-08 06:26:51 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -67,6 +67,7 @@ import net.minecraft.world.phys.MovingObjectPosition;
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
2021-01-08 06:26:51 +01:00
|
|
|
import org.bukkit.Bukkit;
|
2021-03-16 08:19:45 +01:00
|
|
|
+import org.bukkit.Location; // Paper
|
2021-01-08 06:26:51 +01:00
|
|
|
import org.bukkit.Material;
|
|
|
|
import org.bukkit.NamespacedKey;
|
|
|
|
import org.bukkit.Server;
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -467,7 +468,13 @@ public class CraftEventFactory {
|
2021-01-08 06:26:51 +01:00
|
|
|
return callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper start - Add interactionPoint
|
|
|
|
public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, boolean cancelledBlock, EnumHand hand) {
|
|
|
|
+ return callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, hand, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static PlayerInteractEvent callPlayerInteractEvent(EntityHuman who, Action action, BlockPosition position, EnumDirection direction, ItemStack itemstack, boolean cancelledBlock, EnumHand hand, Vec3D hitVec) {
|
|
|
|
+ // Paper end
|
|
|
|
Player player = (who == null) ? null : (Player) who.getBukkitEntity();
|
|
|
|
CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -493,7 +500,10 @@ public class CraftEventFactory {
|
2021-01-08 06:26:51 +01:00
|
|
|
itemInHand = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
- PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND));
|
|
|
|
+ // Paper start
|
|
|
|
+ Location interactionPoint = hitVec == null ? null : new Location(craftWorld, hitVec.x, hitVec.y, hitVec.z);
|
|
|
|
+ PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == EnumHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND), interactionPoint);
|
|
|
|
+ // Paper end
|
|
|
|
if (cancelledBlock) {
|
|
|
|
event.setUseInteractedBlock(Event.Result.DENY);
|
|
|
|
}
|