geforkt von Mirrors/Paper
38be4f873b
Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 2c64d8c4 SPIGOT-7309: Add API for jukebox inventories a6d7e4ca PR-826: Add Sniffer API CraftBukkit Changes: 93813509b SPIGOT-7309: Add API for jukebox inventories 2d5209e8d PR-1153: Handle teleport reason in spreadplayers command f5b61387e SPIGOT-7308: Fix NullPointerException when calling Jukebox#setRecord() 388d458a6 SPIGOT-7306: Fix reset of coords in default teleportTo in EntityPlayer 40b87e1af PR-1150: Add Sniffer API and handle EntityItemDropEvent Spigot Changes: 6ad4b93c SPIGOT-7298: Fix debug stick always permission left click toggle
60 Zeilen
3.8 KiB
Diff
60 Zeilen
3.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Madeline Miller <mnmiller1@me.com>
|
|
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 77eec518940ae41880e395b3dd051d89bd67c319..e6154cf74df39d0c87fc820027adc9641156f888 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 48d499c60739835f603629e248a9a92f54b3cda4..a7c8736391692dfdf028c40d82754adf47fd26dc 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;
|
|
@@ -473,7 +475,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);
|
|
|
|
@@ -499,7 +507,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);
|
|
}
|