PaperMC/patches/server-remapped/fix-PlayerItemHeldEvent-firing-twice.patch
MiniDigger | Martin 95d25d98e8 Move patches around
2021-06-11 14:02:28 +02:00

30 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: chickeneer <emcchickeneer@gmail.com>
Date: Thu, 22 Apr 2021 19:02:07 -0700
Subject: [PATCH] fix PlayerItemHeldEvent firing twice
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCarriedItemPacket.java
@@ -0,0 +0,0 @@ public class ServerboundSetCarriedItemPacket implements Packet<ServerGamePacketL
listener.handleSetCarriedItem(this);
}
+ public int getItemInHandIndex() { return getSlot(); } // Paper - OBFHELPER
public int getSlot() {
return this.slot;
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
PacketUtils.ensureRunningOnSameThread(packet, this, this.player.getLevel());
if (this.player.isImmobile()) return; // CraftBukkit
if (packet.getSlot() >= 0 && packet.getSlot() < Inventory.getSelectionSize()) {
+ if (packet.getItemInHandIndex() == this.player.inventory.selected) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.selected, packet.getSlot());
this.craftServer.getPluginManager().callEvent(event);
if (event.isCancelled()) {