Paper/patches/server/0916-Fix-HumanEntity-drop-not-updating-the-client-inv.patch
Jake Potrebic 0cdce89d59
Fix a bunch of stuff with player spawn locations (#9887)
If a playerdata doesn't contain a valid, loaded world, reset
to the main world spawn point
2023-11-04 14:11:55 -07:00

31 lines
1.6 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 e6326a7cefee568d7639cd3d0166910f8b965b80..8a6095850cece3203eeae474dbf32090f698a32e 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
@@ -755,8 +755,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 - notify client of remote slot change
+ 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
}
@Override