diff --git a/internal/v1_13_R2/src/main/java/com/lishid/openinv/internal/v1_13_R2/SpecialPlayerInventory.java b/internal/v1_13_R2/src/main/java/com/lishid/openinv/internal/v1_13_R2/SpecialPlayerInventory.java index 26e013a..c55e771 100644 --- a/internal/v1_13_R2/src/main/java/com/lishid/openinv/internal/v1_13_R2/SpecialPlayerInventory.java +++ b/internal/v1_13_R2/src/main/java/com/lishid/openinv/internal/v1_13_R2/SpecialPlayerInventory.java @@ -56,7 +56,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP private final CraftInventory inventory = new CraftInventory(this); private boolean playerOnline; private NonNullList items, armor, extraSlots; - private final List> f; + private List> f; public SpecialPlayerInventory(final Player bukkitPlayer, final Boolean online) { super(PlayerDataManager.getHandle(bukkitPlayer)); @@ -73,10 +73,14 @@ 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; + this.f = ImmutableList.of(this.items, this.armor, this.extraSlots); this.playerOnline = true; } } @@ -116,6 +120,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());