From 133305661368475e7236e454457a7aca5527d8a3 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Fri, 19 Jul 2019 07:13:11 -0400 Subject: [PATCH] Correct item order - fixes #107 --- internal/v1_14_R1/pom.xml | 2 +- .../v1_14_R1/SpecialPlayerInventory.java | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/internal/v1_14_R1/pom.xml b/internal/v1_14_R1/pom.xml index 897aefb..0f6212a 100644 --- a/internal/v1_14_R1/pom.xml +++ b/internal/v1_14_R1/pom.xml @@ -32,7 +32,7 @@ org.spigotmc spigot - 1.14.2-R0.1-SNAPSHOT + 1.14.3-R0.1-SNAPSHOT provided diff --git a/internal/v1_14_R1/src/main/java/com/lishid/openinv/internal/v1_14_R1/SpecialPlayerInventory.java b/internal/v1_14_R1/src/main/java/com/lishid/openinv/internal/v1_14_R1/SpecialPlayerInventory.java index 944832f..f4be998 100644 --- a/internal/v1_14_R1/src/main/java/com/lishid/openinv/internal/v1_14_R1/SpecialPlayerInventory.java +++ b/internal/v1_14_R1/src/main/java/com/lishid/openinv/internal/v1_14_R1/SpecialPlayerInventory.java @@ -76,7 +76,10 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP EntityPlayer entityPlayer = PlayerDataManager.getHandle(player); entityPlayer.inventory.transaction.addAll(this.transaction); this.player = entityPlayer; - this.player.inventory.a(this); + for (int i = 0; i < getSize(); ++i) { + this.player.inventory.setItem(i, getRawItem(i)); + } + this.player.inventory.itemInHandIndex = this.itemInHandIndex; this.items = this.player.inventory.items; this.armor = this.player.inventory.armor; this.extraSlots = this.player.inventory.extraSlots; @@ -119,6 +122,19 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP return list.get(i); } + private ItemStack getRawItem(int i) { + NonNullList list = null; + for (NonNullList next : this.f) { + if (i < next.size()) { + list = next; + break; + } + i -= next.size(); + } + + return list == null ? ItemStack.a : list.get(i); + } + @Override public IChatBaseComponent getDisplayName() { return new ChatMessage(this.player.getName());