--- a/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/DispenserBlockEntity.java
@@ -8,17 +8,55 @@
 import net.minecraft.util.RandomSource;
 import net.minecraft.world.ContainerHelper;
 import net.minecraft.world.entity.player.Inventory;
+import net.minecraft.world.entity.player.Player;
 import net.minecraft.world.inventory.AbstractContainerMenu;
 import net.minecraft.world.inventory.DispenserMenu;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.level.block.state.BlockState;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
 
 public class DispenserBlockEntity extends RandomizableContainerBlockEntity {
+
     public static final int CONTAINER_SIZE = 9;
-    private NonNullList<ItemStack> items = NonNullList.withSize(9, ItemStack.EMPTY);
+    private NonNullList<ItemStack> items;
+
+    // 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.items;
+    }
+
+    public void onOpen(CraftHumanEntity who) {
+        this.transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        this.transaction.remove(who);
+    }
+
+    public List<HumanEntity> getViewers() {
+        return this.transaction;
+    }
+
+    @Override
+    public int getMaxStackSize() {
+        return this.maxStack;
+    }
+
+    public void setMaxStackSize(int size) {
+        this.maxStack = size;
+    }
+    // CraftBukkit end
 
     protected DispenserBlockEntity(BlockEntityType<?> type, BlockPos pos, BlockState state) {
         super(type, pos, state);
+        this.items = NonNullList.withSize(9, ItemStack.EMPTY);
     }
 
     public DispenserBlockEntity(BlockPos pos, BlockState state) {
@@ -31,12 +69,12 @@
     }
 
     public int getRandomSlot(RandomSource random) {
-        this.unpackLootTable(null);
+        this.unpackLootTable((Player) null);
         int i = -1;
         int j = 1;
 
-        for (int k = 0; k < this.items.size(); k++) {
-            if (!this.items.get(k).isEmpty() && random.nextInt(j++) == 0) {
+        for (int k = 0; k < this.items.size(); ++k) {
+            if (!((ItemStack) this.items.get(k)).isEmpty() && random.nextInt(j++) == 0) {
                 i = k;
             }
         }
@@ -47,16 +85,18 @@
     public ItemStack insertItem(ItemStack stack) {
         int i = this.getMaxStackSize(stack);
 
-        for (int j = 0; j < this.items.size(); j++) {
-            ItemStack itemStack = this.items.get(j);
-            if (itemStack.isEmpty() || ItemStack.isSameItemSameComponents(stack, itemStack)) {
-                int k = Math.min(stack.getCount(), i - itemStack.getCount());
+        for (int j = 0; j < this.items.size(); ++j) {
+            ItemStack itemstack1 = (ItemStack) this.items.get(j);
+
+            if (itemstack1.isEmpty() || ItemStack.isSameItemSameComponents(stack, itemstack1)) {
+                int k = Math.min(stack.getCount(), i - itemstack1.getCount());
+
                 if (k > 0) {
-                    if (itemStack.isEmpty()) {
+                    if (itemstack1.isEmpty()) {
                         this.setItem(j, stack.split(k));
                     } else {
                         stack.shrink(k);
-                        itemStack.grow(k);
+                        itemstack1.grow(k);
                     }
                 }
 
@@ -81,6 +121,7 @@
         if (!this.tryLoadLootTable(nbt)) {
             ContainerHelper.loadAllItems(nbt, this.items, registryLookup);
         }
+
     }
 
     @Override
@@ -89,6 +130,7 @@
         if (!this.trySaveLootTable(nbt)) {
             ContainerHelper.saveAllItems(nbt, this.items, registryLookup);
         }
+
     }
 
     @Override
