mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-30 19:40:37 +01:00
Fix PlayerItemHeldEvent firing twice (#5534)
Co-authored by: chickeneer <emcchickeneer@gmail.com>
This commit is contained in:
parent
b20b05e631
commit
accd70d21f
1 changed files with 30 additions and 0 deletions
|
@ -0,0 +1,30 @@
|
|||
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/PacketPlayInHeldItemSlot.java b/src/main/java/net/minecraft/network/protocol/game/PacketPlayInHeldItemSlot.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/network/protocol/game/PacketPlayInHeldItemSlot.java
|
||||
+++ b/src/main/java/net/minecraft/network/protocol/game/PacketPlayInHeldItemSlot.java
|
||||
@@ -0,0 +0,0 @@ public class PacketPlayInHeldItemSlot implements Packet<PacketListenerPlayIn> {
|
||||
packetlistenerplayin.a(this);
|
||||
}
|
||||
|
||||
+ public int getItemInHandIndex() { return b(); } // Paper - OBFHELPER
|
||||
public int b() {
|
||||
return this.itemInHandIndex;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/network/PlayerConnection.java b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ public class PlayerConnection implements PacketListenerPlayIn {
|
||||
PlayerConnectionUtils.ensureMainThread(packetplayinhelditemslot, this, this.player.getWorldServer());
|
||||
if (this.player.isFrozen()) return; // CraftBukkit
|
||||
if (packetplayinhelditemslot.b() >= 0 && packetplayinhelditemslot.b() < PlayerInventory.getHotbarSize()) {
|
||||
+ if (packetplayinhelditemslot.getItemInHandIndex() == this.player.inventory.itemInHandIndex) { return; } // Paper - don't fire itemheldevent when there wasn't a slot change
|
||||
PlayerItemHeldEvent event = new PlayerItemHeldEvent(this.getPlayer(), this.player.inventory.itemInHandIndex, packetplayinhelditemslot.b());
|
||||
this.server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
Loading…
Add table
Reference in a new issue