--- a/net/minecraft/world/entity/player/PlayerInventory.java
+++ b/net/minecraft/world/entity/player/PlayerInventory.java
@@ -24,6 +24,13 @@
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.level.block.state.IBlockData;
 
+// CraftBukkit start
+import java.util.ArrayList;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
 public class PlayerInventory implements IInventory, INamableTileEntity {
 
     public static final int POP_TIME_DURATION = 5;
@@ -39,6 +46,54 @@
     public final EntityHuman player;
     private int timesChanged;
 
+    // CraftBukkit start - add fields and methods
+    public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+    private int maxStack = MAX_STACK;
+
+    public List<ItemStack> getContents() {
+        List<ItemStack> combined = new ArrayList<ItemStack>(items.size() + armor.size() + offhand.size());
+        for (List<net.minecraft.world.item.ItemStack> sub : this.compartments) {
+            combined.addAll(sub);
+        }
+
+        return combined;
+    }
+
+    public List<ItemStack> getArmorContents() {
+        return this.armor;
+    }
+
+    public void onOpen(CraftHumanEntity who) {
+        transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        transaction.remove(who);
+    }
+
+    public List<HumanEntity> getViewers() {
+        return transaction;
+    }
+
+    public org.bukkit.inventory.InventoryHolder getOwner() {
+        return this.player.getBukkitEntity();
+    }
+
+    @Override
+    public int getMaxStackSize() {
+        return maxStack;
+    }
+
+    public void setMaxStackSize(int size) {
+        maxStack = size;
+    }
+
+    @Override
+    public Location getLocation() {
+        return player.getBukkitEntity().getLocation();
+    }
+    // CraftBukkit end
+
     public PlayerInventory(EntityHuman entityhuman) {
         this.items = NonNullList.withSize(36, ItemStack.EMPTY);
         this.armor = NonNullList.withSize(4, ItemStack.EMPTY);
@@ -59,6 +114,28 @@
         return !itemstack.isEmpty() && ItemStack.isSameItemSameComponents(itemstack, itemstack1) && itemstack.isStackable() && itemstack.getCount() < this.getMaxStackSize(itemstack);
     }
 
+    // CraftBukkit start - Watch method above! :D
+    public int canHold(ItemStack itemstack) {
+        int remains = itemstack.getCount();
+        for (int i = 0; i < this.items.size(); ++i) {
+            ItemStack itemstack1 = this.getItem(i);
+            if (itemstack1.isEmpty()) return itemstack.getCount();
+
+            if (this.hasRemainingSpaceForItem(itemstack1, itemstack)) {
+                remains -= (itemstack1.getMaxStackSize() < this.getMaxStackSize() ? itemstack1.getMaxStackSize() : this.getMaxStackSize()) - itemstack1.getCount();
+            }
+            if (remains <= 0) return itemstack.getCount();
+        }
+        ItemStack offhandItemStack = this.getItem(this.items.size() + this.armor.size());
+        if (this.hasRemainingSpaceForItem(offhandItemStack, itemstack)) {
+            remains -= (offhandItemStack.getMaxStackSize() < this.getMaxStackSize() ? offhandItemStack.getMaxStackSize() : this.getMaxStackSize()) - offhandItemStack.getCount();
+        }
+        if (remains <= 0) return itemstack.getCount();
+
+        return itemstack.getCount() - remains;
+    }
+    // CraftBukkit end
+
     public int getFreeSlot() {
         for (int i = 0; i < this.items.size(); ++i) {
             if (((ItemStack) this.items.get(i)).isEmpty()) {
