--- a/net/minecraft/world/inventory/InventoryMerchant.java
+++ b/net/minecraft/world/inventory/InventoryMerchant.java
@@ -11,6 +11,16 @@
 import net.minecraft.world.item.trading.MerchantRecipe;
 import net.minecraft.world.item.trading.MerchantRecipeList;
 
+// CraftBukkit start
+import java.util.List;
+import net.minecraft.world.entity.npc.EntityVillager;
+import net.minecraft.world.entity.npc.EntityVillagerAbstract;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftAbstractVillager;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
 public class InventoryMerchant implements IInventory {
 
     private final IMerchant merchant;
@@ -20,6 +30,46 @@
     public int selectionHint;
     private int futureXp;
 
+    // CraftBukkit start - add fields and methods
+    public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+    private int maxStack = MAX_STACK;
+
+    public List<ItemStack> getContents() {
+        return this.itemStacks;
+    }
+
+    public void onOpen(CraftHumanEntity who) {
+        transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        transaction.remove(who);
+        merchant.setTradingPlayer((EntityHuman) null); // SPIGOT-4860
+    }
+
+    public List<HumanEntity> getViewers() {
+        return transaction;
+    }
+
+    @Override
+    public int getMaxStackSize() {
+        return maxStack;
+    }
+
+    public void setMaxStackSize(int i) {
+        maxStack = i;
+    }
+
+    public org.bukkit.inventory.InventoryHolder getOwner() {
+        return (merchant instanceof EntityVillagerAbstract) ? (CraftAbstractVillager) ((EntityVillagerAbstract) this.merchant).getBukkitEntity() : null;
+    }
+
+    @Override
+    public Location getLocation() {
+        return (merchant instanceof EntityVillager) ? ((EntityVillager) this.merchant).getBukkitEntity().getLocation() : null;
+    }
+    // CraftBukkit end
+
     public InventoryMerchant(IMerchant imerchant) {
         this.itemStacks = NonNullList.withSize(3, ItemStack.EMPTY);
         this.merchant = imerchant;
