geforkt von Mirrors/Paper
d8847bc1f3
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: fde5602a PR-927: Add PlayerRecipeBookSettingsChangeEvent 949ff217 PR-930: Add methods to get/set evoker fang attack delay f6f7c79d SPIGOT-7514, PR-929: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics d40e22da PR-712: Add API to get full result of crafting items CraftBukkit Changes: c8feb0629 PR-1291: Improve precondition message in Entity#playEffect 482c56a00 PR-1285: Add PlayerRecipeBookSettingsChangeEvent cdf798800 PR-1290: Add methods to get/set evoker fang attack delay 2c1b5f78f SPIGOT-7514, PR-1289: Add "Enchantment Roll" API to enchant items according to Minecraft mechanics 6aa644ae9 PR-992: Add API to get full result of crafting items ffb1319bc PR-1287: Fix scoreboards not updating in Player#setStatistic
46 Zeilen
2.8 KiB
Diff
46 Zeilen
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: RodneyMKay <36546810+RodneyMKay@users.noreply.github.com>
|
|
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 b016f84ed1e99286073daf148612896ae470d222..236ab643cdd65b3572860aedf1f5ac18ff96139a 100644
|
|
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
|
|
@@ -943,7 +943,14 @@ public class ServerGamePacketListenerImpl extends ServerCommonPacketListenerImpl
|
|
this.disconnect("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
|
|
+ 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
|
|
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())));
|
|
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 395cecc385e4126a7534ac9aeb15cf323efab03e..96d664c28738d6090f7067761c2978dd1aa0fd0e 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/player/Inventory.java
|
|
@@ -174,7 +174,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
|
|
ItemStack itemstack = (ItemStack) this.items.get(this.selected);
|
|
|
|
this.items.set(this.selected, (ItemStack) this.items.get(slot));
|