aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch
diff options
context:
space:
mode:
authorJake Potrebic <[email protected]>2023-06-12 16:51:45 -0700
committerGitHub <[email protected]>2023-06-12 16:51:45 -0700
commitc287e921a96438964f32f3c4e394d6809e0d06fa (patch)
treefcc826670454d8a8f5547838414583ce5f1df02d /patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch
parentb48e2e352e21c56d6a9e90bb8d9e548d3658a691 (diff)
downloadPaper-c287e921a96438964f32f3c4e394d6809e0d06fa.tar.gz
Paper-c287e921a96438964f32f3c4e394d6809e0d06fa.zip
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#9301)1.20
Diffstat (limited to 'patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch')
-rw-r--r--patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch b/patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch
new file mode 100644
index 0000000000..b411c78421
--- /dev/null
+++ b/patches/server/0533-Implement-API-to-expose-exact-interaction-point.patch
@@ -0,0 +1,59 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Madeline Miller <[email protected]>
+Date: Mon, 4 Jan 2021 16:40:27 +1000
+Subject: [PATCH] Implement API to expose exact interaction point
+
+
+diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+index 180dc7ec0202fd6c24682631dedc066976f17fa4..43221bf57fb4eeb70823c12b48f4df0bb817eb0b 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+@@ -517,7 +517,7 @@ public class ServerPlayerGameMode {
+ cancelledBlock = true;
+ }
+
+- PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand);
++ PlayerInteractEvent event = CraftEventFactory.callPlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, blockposition, hitResult.getDirection(), stack, cancelledBlock, hand, hitResult.getLocation()); // Paper
+ this.firedInteract = true;
+ this.interactResult = event.useItemInHand() == Event.Result.DENY;
+ this.interactPosition = blockposition.immutable();
+diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+index edd27b8e2535b520c4f6e6309269ab84799f2a3a..3799eec69ef45c77e032faee91ce45205dcd3675 100644
+--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
++++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+@@ -58,7 +58,9 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
+ import net.minecraft.world.phys.BlockHitResult;
+ import net.minecraft.world.phys.EntityHitResult;
+ import net.minecraft.world.phys.HitResult;
++import net.minecraft.world.phys.Vec3;
+ import org.bukkit.Bukkit;
++import org.bukkit.Location; // Paper
+ import org.bukkit.Material;
+ import org.bukkit.NamespacedKey;
+ import org.bukkit.Server;
+@@ -492,7 +494,13 @@ public class CraftEventFactory {
+ return CraftEventFactory.callPlayerInteractEvent(who, action, position, direction, itemstack, false, hand);
+ }
+
++ // Paper start - Add interactionPoint
+ public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand) {
++ return callPlayerInteractEvent(who, action, position, direction, itemstack, cancelledBlock, hand, null);
++ }
++
++ public static PlayerInteractEvent callPlayerInteractEvent(net.minecraft.world.entity.player.Player who, Action action, BlockPos position, Direction direction, ItemStack itemstack, boolean cancelledBlock, InteractionHand hand, Vec3 hitVec) {
++ // Paper end
+ Player player = (who == null) ? null : (Player) who.getBukkitEntity();
+ CraftItemStack itemInHand = CraftItemStack.asCraftMirror(itemstack);
+
+@@ -518,7 +526,10 @@ public class CraftEventFactory {
+ itemInHand = null;
+ }
+
+- PlayerInteractEvent event = new PlayerInteractEvent(player, action, itemInHand, blockClicked, blockFace, (hand == null) ? null : ((hand == InteractionHand.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 == InteractionHand.OFF_HAND) ? EquipmentSlot.OFF_HAND : EquipmentSlot.HAND), interactionPoint);
++ // Paper end
+ if (cancelledBlock) {
+ event.setUseInteractedBlock(Event.Result.DENY);
+ }