From 87f8ab3fb3159b6d6fb99b68b8329001ac8c993d Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Fri, 30 Jul 2021 19:08:43 +1000 Subject: [PATCH] SPIGOT-6552: Some inventory types reset cursor on switch By: DerFrZocker --- .../minecraft/server/level/EntityPlayer.patch | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch index 449c2d7bf4..85ca815560 100644 --- a/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch +++ b/paper-server/nms-patches/net/minecraft/server/level/EntityPlayer.patch @@ -654,7 +654,18 @@ } @Override -@@ -1016,6 +1333,24 @@ +@@ -1009,13 +1326,35 @@ + if (itileinventory == null) { + return OptionalInt.empty(); + } else { ++ // CraftBukkit start - SPIGOT-6552: Handle inventory closing in CraftEventFactory#callInventoryOpenEvent(...) ++ /* + if (this.containerMenu != this.inventoryMenu) { + this.closeInventory(); + } ++ */ ++ // CraftBukkit end + this.nextContainerCounter(); Container container = itileinventory.createMenu(this.containerCounter, this.getInventory(), this); @@ -679,7 +690,7 @@ if (container == null) { if (this.isSpectator()) { this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); -@@ -1023,9 +1358,11 @@ +@@ -1023,9 +1362,11 @@ return OptionalInt.empty(); } else { @@ -693,7 +704,7 @@ return OptionalInt.of(this.containerCounter); } } -@@ -1038,13 +1375,24 @@ +@@ -1038,13 +1379,24 @@ @Override public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { @@ -720,7 +731,7 @@ this.initMenu(this.containerMenu); } -@@ -1068,6 +1416,7 @@ +@@ -1068,6 +1420,7 @@ @Override public void closeInventory() { @@ -728,7 +739,7 @@ this.connection.sendPacket(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.o(); } -@@ -1097,7 +1446,7 @@ +@@ -1097,7 +1450,7 @@ @Override public void a(Statistic statistic, int i) { this.stats.b(this, statistic, i); @@ -737,7 +748,7 @@ scoreboardscore.addScore(i); }); } -@@ -1105,7 +1454,7 @@ +@@ -1105,7 +1458,7 @@ @Override public void a(Statistic statistic) { this.stats.setStatistic(this, statistic, 0); @@ -746,7 +757,7 @@ } @Override -@@ -1121,7 +1470,7 @@ +@@ -1121,7 +1474,7 @@ for (int j = 0; j < i; ++j) { MinecraftKey minecraftkey = aminecraftkey1[j]; @@ -755,7 +766,7 @@ Objects.requireNonNull(list); optional.ifPresent(list::add); -@@ -1156,7 +1505,16 @@ +@@ -1156,7 +1509,16 @@ public void triggerHealthUpdate() { this.lastSentHealth = -1.0E8F; @@ -772,7 +783,7 @@ @Override public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { -@@ -1211,11 +1569,12 @@ +@@ -1211,11 +1573,12 @@ this.lastSentExp = -1; this.lastSentHealth = -1.0F; this.lastSentFood = -1; @@ -786,7 +797,7 @@ } @Override -@@ -1337,7 +1696,20 @@ +@@ -1337,7 +1700,20 @@ return s; } @@ -807,7 +818,7 @@ this.chatVisibility = packetplayinsettings.d(); this.canChatColor = packetplayinsettings.e(); this.textFilteringEnabled = packetplayinsettings.h(); -@@ -1407,7 +1779,7 @@ +@@ -1407,7 +1783,7 @@ this.camera = (Entity) (entity == null ? this : entity); if (entity1 != this.camera) { this.connection.sendPacket(new PacketPlayOutCamera(this.camera)); @@ -816,7 +827,7 @@ } } -@@ -1436,7 +1808,7 @@ +@@ -1436,7 +1812,7 @@ @Nullable public IChatBaseComponent getPlayerListName() { @@ -825,7 +836,7 @@ } @Override -@@ -1457,9 +1829,16 @@ +@@ -1457,9 +1833,16 @@ return this.advancements; } @@ -842,7 +853,7 @@ if (worldserver == this.level) { this.connection.b(d0, d1, d2, f, f1); } else { -@@ -1479,6 +1858,9 @@ +@@ -1479,6 +1862,9 @@ this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().updateClient(this); } @@ -852,7 +863,7 @@ } -@@ -1634,4 +2016,144 @@ +@@ -1634,4 +2020,144 @@ }); return this.a(itemstack, false, true) != null; }