Improve diff in ServerPlayer#openHorseInventory

This commit is contained in:
Bjarne Koll 2024-12-19 21:48:24 +01:00
parent 993db46961
commit 68bbd2e202
No known key found for this signature in database
GPG key ID: 9576DAF3FDDB088F

View file

@ -966,12 +966,8 @@
@Override
public void openHorseInventory(AbstractHorse horse, Container inventory) {
- if (this.containerMenu != this.inventoryMenu) {
- this.closeContainer();
- }
-
+ // CraftBukkit start - Inventory open hook
this.nextContainerCounter();
+ this.nextContainerCounter(); // Moved up from below
+ AbstractContainerMenu container = new HorseInventoryMenu(this.containerCounter, this.getInventory(), inventory, horse, horse.getInventoryColumns());
+ container.setTitle(horse.getDisplayName());
+ container = org.bukkit.craftbukkit.event.CraftEventFactory.callInventoryOpenEvent(this, container);
@ -981,10 +977,12 @@
+ return;
+ }
+ // CraftBukkit end
+ if (this.containerMenu != this.inventoryMenu) {
if (this.containerMenu != this.inventoryMenu) {
- this.closeContainer();
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.OPEN_NEW); // Paper - Inventory close reason
+ }
+
}
- this.nextContainerCounter();
+ // this.nextContainerCounter(); // CraftBukkit - moved up
int inventoryColumns = horse.getInventoryColumns();
this.connection.send(new ClientboundHorseScreenOpenPacket(this.containerCounter, inventoryColumns, horse.getId()));