PaperMC/patches/server/0818-Fix-HumanEntity-drop-not-updating-the-client-inv.patch
Riley Park f17519338b
Expose server build information (#10729)
* Expose server build information

* squash patches

* final tweaks

---------

Co-authored-by: Jake Potrebic <jake.m.potrebic@gmail.com>
Co-authored-by: masmc05 <masmc05@gmail.com>
2024-05-15 17:06:59 -07:00

30 lines
1.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jake Potrebic <jake.m.potrebic@gmail.com>
Date: Sun, 10 Oct 2021 18:18:01 -0700
Subject: [PATCH] Fix HumanEntity#drop not updating the client inv
== AT ==
public net.minecraft.server.level.ServerPlayer containerSynchronizer
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
index e1150d36de56466ad9fdd5f2cdb4c30855d4af70..3d36d79a4e7f16f6face3465cdf54656984f3ebc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -750,8 +750,15 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
// Paper end
@Override
public boolean dropItem(boolean dropAll) {
- if (!(this.getHandle() instanceof ServerPlayer)) return false;
- return ((ServerPlayer) this.getHandle()).drop(dropAll);
+ // Paper start - Fix HumanEntity#drop not updating the client inv
+ if (!(this.getHandle() instanceof ServerPlayer player)) return false;
+ boolean success = player.drop(dropAll);
+ if (!success) return false;
+ final net.minecraft.world.entity.player.Inventory inv = player.getInventory();
+ final java.util.OptionalInt optionalSlot = player.containerMenu.findSlot(inv, inv.selected);
+ optionalSlot.ifPresent(slot -> player.containerSynchronizer.sendSlotChange(player.containerMenu, slot, inv.getSelected()));
+ return true;
+ // Paper end - Fix HumanEntity#drop not updating the client inv
}
@Override