13
0
geforkt von Mirrors/Paper

SPIGOT-6552: Some inventory types reset cursor on switch

By: DerFrZocker <derrieple@gmail.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2021-07-30 19:08:43 +10:00
Ursprung af0d8b70df
Commit 87f8ab3fb3

Datei anzeigen

@ -654,7 +654,18 @@
} }
@Override @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(); this.nextContainerCounter();
Container container = itileinventory.createMenu(this.containerCounter, this.getInventory(), this); Container container = itileinventory.createMenu(this.containerCounter, this.getInventory(), this);
@ -679,7 +690,7 @@
if (container == null) { if (container == null) {
if (this.isSpectator()) { if (this.isSpectator()) {
this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true); this.a((IChatBaseComponent) (new ChatMessage("container.spectatorCantOpen")).a(EnumChatFormat.RED), true);
@@ -1023,9 +1358,11 @@ @@ -1023,9 +1362,11 @@
return OptionalInt.empty(); return OptionalInt.empty();
} else { } else {
@ -693,7 +704,7 @@
return OptionalInt.of(this.containerCounter); return OptionalInt.of(this.containerCounter);
} }
} }
@@ -1038,13 +1375,24 @@ @@ -1038,13 +1379,24 @@
@Override @Override
public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) { public void openHorseInventory(EntityHorseAbstract entityhorseabstract, IInventory iinventory) {
@ -720,7 +731,7 @@
this.initMenu(this.containerMenu); this.initMenu(this.containerMenu);
} }
@@ -1068,6 +1416,7 @@ @@ -1068,6 +1420,7 @@
@Override @Override
public void closeInventory() { public void closeInventory() {
@ -728,7 +739,7 @@
this.connection.sendPacket(new PacketPlayOutCloseWindow(this.containerMenu.containerId)); this.connection.sendPacket(new PacketPlayOutCloseWindow(this.containerMenu.containerId));
this.o(); this.o();
} }
@@ -1097,7 +1446,7 @@ @@ -1097,7 +1450,7 @@
@Override @Override
public void a(Statistic<?> statistic, int i) { public void a(Statistic<?> statistic, int i) {
this.stats.b(this, statistic, i); this.stats.b(this, statistic, i);
@ -737,7 +748,7 @@
scoreboardscore.addScore(i); scoreboardscore.addScore(i);
}); });
} }
@@ -1105,7 +1454,7 @@ @@ -1105,7 +1458,7 @@
@Override @Override
public void a(Statistic<?> statistic) { public void a(Statistic<?> statistic) {
this.stats.setStatistic(this, statistic, 0); this.stats.setStatistic(this, statistic, 0);
@ -746,7 +757,7 @@
} }
@Override @Override
@@ -1121,7 +1470,7 @@ @@ -1121,7 +1474,7 @@
for (int j = 0; j < i; ++j) { for (int j = 0; j < i; ++j) {
MinecraftKey minecraftkey = aminecraftkey1[j]; MinecraftKey minecraftkey = aminecraftkey1[j];
@ -755,7 +766,7 @@
Objects.requireNonNull(list); Objects.requireNonNull(list);
optional.ifPresent(list::add); optional.ifPresent(list::add);
@@ -1156,7 +1505,16 @@ @@ -1156,7 +1509,16 @@
public void triggerHealthUpdate() { public void triggerHealthUpdate() {
this.lastSentHealth = -1.0E8F; this.lastSentHealth = -1.0E8F;
@ -772,7 +783,7 @@
@Override @Override
public void a(IChatBaseComponent ichatbasecomponent, boolean flag) { public void a(IChatBaseComponent ichatbasecomponent, boolean flag) {
@@ -1211,11 +1569,12 @@ @@ -1211,11 +1573,12 @@
this.lastSentExp = -1; this.lastSentExp = -1;
this.lastSentHealth = -1.0F; this.lastSentHealth = -1.0F;
this.lastSentFood = -1; this.lastSentFood = -1;
@ -786,7 +797,7 @@
} }
@Override @Override
@@ -1337,7 +1696,20 @@ @@ -1337,7 +1700,20 @@
return s; return s;
} }
@ -807,7 +818,7 @@
this.chatVisibility = packetplayinsettings.d(); this.chatVisibility = packetplayinsettings.d();
this.canChatColor = packetplayinsettings.e(); this.canChatColor = packetplayinsettings.e();
this.textFilteringEnabled = packetplayinsettings.h(); this.textFilteringEnabled = packetplayinsettings.h();
@@ -1407,7 +1779,7 @@ @@ -1407,7 +1783,7 @@
this.camera = (Entity) (entity == null ? this : entity); this.camera = (Entity) (entity == null ? this : entity);
if (entity1 != this.camera) { if (entity1 != this.camera) {
this.connection.sendPacket(new PacketPlayOutCamera(this.camera)); this.connection.sendPacket(new PacketPlayOutCamera(this.camera));
@ -816,7 +827,7 @@
} }
} }
@@ -1436,7 +1808,7 @@ @@ -1436,7 +1812,7 @@
@Nullable @Nullable
public IChatBaseComponent getPlayerListName() { public IChatBaseComponent getPlayerListName() {
@ -825,7 +836,7 @@
} }
@Override @Override
@@ -1457,9 +1829,16 @@ @@ -1457,9 +1833,16 @@
return this.advancements; return this.advancements;
} }
@ -842,7 +853,7 @@
if (worldserver == this.level) { if (worldserver == this.level) {
this.connection.b(d0, d1, d2, f, f1); this.connection.b(d0, d1, d2, f, f1);
} else { } else {
@@ -1479,6 +1858,9 @@ @@ -1479,6 +1862,9 @@
this.server.getPlayerList().a(this, worldserver); this.server.getPlayerList().a(this, worldserver);
this.server.getPlayerList().updateClient(this); this.server.getPlayerList().updateClient(this);
} }
@ -852,7 +863,7 @@
} }
@@ -1634,4 +2016,144 @@ @@ -1634,4 +2020,144 @@
}); });
return this.a(itemstack, false, true) != null; return this.a(itemstack, false, true) != null;
} }