diff options
author | Jakub Zacek <[email protected]> | 2024-07-15 23:35:51 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-15 17:35:51 -0400 |
commit | 2cd8c461af74f0a524878dcdffba86cd105c48c6 (patch) | |
tree | ac107a76fe3d6cdd2e6ef5804ef3cba152957e4c /patches/server/0875-Add-PlayerPickItemEvent.patch | |
parent | b57b24d549c65ddc5eb3edcc1ecc6aad2826dbd8 (diff) | |
download | Paper-2cd8c461af74f0a524878dcdffba86cd105c48c6.tar.gz Paper-2cd8c461af74f0a524878dcdffba86cd105c48c6.zip |
Add OMINOUS_ITEM_SPAWNER SpawnReason (#10897)
Diffstat (limited to 'patches/server/0875-Add-PlayerPickItemEvent.patch')
-rw-r--r-- | patches/server/0875-Add-PlayerPickItemEvent.patch | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/patches/server/0875-Add-PlayerPickItemEvent.patch b/patches/server/0875-Add-PlayerPickItemEvent.patch new file mode 100644 index 0000000000..b9ddd8ed60 --- /dev/null +++ b/patches/server/0875-Add-PlayerPickItemEvent.patch @@ -0,0 +1,48 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: RodneyMKay <[email protected]> +Date: Wed, 8 Sep 2021 21:34:01 +0200 +Subject: [PATCH] Add PlayerPickItemEvent + + +diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +index 7ad73ec156417a5c8b826744f1c3ceefc0b129ce..0ed03a8ec85d8491d96c7b3ac3feff805a773539 100644 +--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java ++++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +@@ -935,8 +935,17 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl + this.disconnect(Component.literal("Invalid hotbar selection (Hacking?)"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_ACTION); // Paper - kick event cause + return; + } +- this.player.getInventory().pickSlot(packet.getSlot()); // Paper - Diff above if changed + // Paper end - validate pick item position ++ // Paper start - Add PlayerPickItemEvent ++ Player bukkitPlayer = this.player.getBukkitEntity(); ++ int targetSlot = this.player.getInventory().getSuitableHotbarSlot(); ++ int sourceSlot = packet.getSlot(); ++ ++ io.papermc.paper.event.player.PlayerPickItemEvent event = new io.papermc.paper.event.player.PlayerPickItemEvent(bukkitPlayer, targetSlot, sourceSlot); ++ if (!event.callEvent()) return; ++ ++ this.player.getInventory().pickSlot(event.getSourceSlot(), event.getTargetSlot()); ++ // Paper end - Add PlayerPickItemEvent + this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, this.player.getInventory().selected, this.player.getInventory().getItem(this.player.getInventory().selected))); + this.player.connection.send(new ClientboundContainerSetSlotPacket(-2, 0, packet.getSlot(), this.player.getInventory().getItem(packet.getSlot()))); + this.player.connection.send(new ClientboundSetCarriedItemPacket(this.player.getInventory().selected)); +diff --git a/src/main/java/net/minecraft/world/entity/player/Inventory.java b/src/main/java/net/minecraft/world/entity/player/Inventory.java +index 688ed0c32b05b0135b94ec05738cdc6ff8dcb677..a62e7354bf67a66bdf9cd7c8f5d2e8f6bcacc74f 100644 +--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java ++++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java +@@ -171,7 +171,13 @@ public class Inventory implements Container, Nameable { + } + + public void pickSlot(int slot) { +- this.selected = this.getSuitableHotbarSlot(); ++ // Paper start - Add PlayerPickItemEvent ++ pickSlot(slot, this.getSuitableHotbarSlot()); ++ } ++ ++ public void pickSlot(int slot, int targetSlot) { ++ this.selected = targetSlot; ++ // Paper end - Add PlayerPickItemEvent + ItemStack itemstack = (ItemStack) this.items.get(this.selected); + + this.items.set(this.selected, (ItemStack) this.items.get(slot)); |