--- a/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
+++ b/net/minecraft/world/level/block/entity/BarrelBlockEntity.java
@@ -1,6 +1,7 @@
 package net.minecraft.world.level.block.entity;
 
 import net.minecraft.core.BlockPos;
+import net.minecraft.core.Direction;
 import net.minecraft.core.NonNullList;
 import net.minecraft.core.Vec3i;
 import net.minecraft.nbt.CompoundTag;
@@ -18,39 +19,82 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.block.BarrelBlock;
 import net.minecraft.world.level.block.state.BlockState;
+// CraftBukkit start
+import java.util.ArrayList;
+import java.util.List;
+import org.bukkit.craftbukkit.v1_19_R1.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
 
 public class BarrelBlockEntity extends RandomizableContainerBlockEntity {
-    private NonNullList<ItemStack> items = NonNullList.withSize(27, ItemStack.EMPTY);
-    public ContainerOpenersCounter openersCounter = new ContainerOpenersCounter() {
-        @Override
-        protected void onOpen(Level world, BlockPos pos, BlockState state) {
-            BarrelBlockEntity.this.playSound(state, SoundEvents.BARREL_OPEN);
-            BarrelBlockEntity.this.updateBlockState(state, true);
-        }
 
-        @Override
-        protected void onClose(Level world, BlockPos pos, BlockState state) {
-            BarrelBlockEntity.this.playSound(state, SoundEvents.BARREL_CLOSE);
-            BarrelBlockEntity.this.updateBlockState(state, false);
-        }
+    // CraftBukkit start - add fields and methods
+    public List<HumanEntity> transaction = new ArrayList<>();
+    private int maxStack = MAX_STACK;
 
-        @Override
-        protected void openerCountChanged(Level world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount) {
-        }
+    @Override
+    public List<ItemStack> getContents() {
+        return this.items;
+    }
 
-        @Override
-        protected boolean isOwnContainer(Player player) {
-            if (player.containerMenu instanceof ChestMenu) {
-                Container container = ((ChestMenu)player.containerMenu).getContainer();
-                return container == BarrelBlockEntity.this;
-            } else {
-                return false;
-            }
-        }
-    };
+    @Override
+    public void onOpen(CraftHumanEntity who) {
+        this.transaction.add(who);
+    }
+
+    @Override
+    public void onClose(CraftHumanEntity who) {
+        this.transaction.remove(who);
+    }
+
+    @Override
+    public List<HumanEntity> getViewers() {
+        return this.transaction;
+    }
+
+    @Override
+    public int getMaxStackSize() {
+       return this.maxStack;
+    }
+
+    @Override
+    public void setMaxStackSize(int i) {
+        this.maxStack = i;
+    }
+    // CraftBukkit end
+    private NonNullList<ItemStack> items;
+    public ContainerOpenersCounter openersCounter;
 
     public BarrelBlockEntity(BlockPos pos, BlockState state) {
         super(BlockEntityType.BARREL, pos, state);
+        this.items = NonNullList.withSize(27, ItemStack.EMPTY);
+        this.openersCounter = new ContainerOpenersCounter() {
+            @Override
+            protected void onOpen(Level world, BlockPos pos, BlockState state) {
+                BarrelBlockEntity.this.playSound(state, SoundEvents.BARREL_OPEN);
+                BarrelBlockEntity.this.updateBlockState(state, true);
+            }
+
+            @Override
+            protected void onClose(Level world, BlockPos pos, BlockState state) {
+                BarrelBlockEntity.this.playSound(state, SoundEvents.BARREL_CLOSE);
+                BarrelBlockEntity.this.updateBlockState(state, false);
+            }
+
+            @Override
+            protected void openerCountChanged(Level world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount) {}
+
+            @Override
+            protected boolean isOwnContainer(Player player) {
+                if (player.containerMenu instanceof ChestMenu) {
+                    Container iinventory = ((ChestMenu) player.containerMenu).getContainer();
+
+                    return iinventory == BarrelBlockEntity.this;
+                } else {
+                    return false;
+                }
+            }
+        };
     }
 
     @Override
@@ -121,14 +165,15 @@
     }
 
     public void updateBlockState(BlockState state, boolean open) {
-        this.level.setBlock(this.getBlockPos(), state.setValue(BarrelBlock.OPEN, Boolean.valueOf(open)), 3);
+        this.level.setBlock(this.getBlockPos(), (BlockState) state.setValue(BarrelBlock.OPEN, open), 3);
     }
 
     public void playSound(BlockState state, SoundEvent soundEvent) {
-        Vec3i vec3i = state.getValue(BarrelBlock.FACING).getNormal();
-        double d = (double)this.worldPosition.getX() + 0.5D + (double)vec3i.getX() / 2.0D;
-        double e = (double)this.worldPosition.getY() + 0.5D + (double)vec3i.getY() / 2.0D;
-        double f = (double)this.worldPosition.getZ() + 0.5D + (double)vec3i.getZ() / 2.0D;
-        this.level.playSound((Player)null, d, e, f, soundEvent, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F);
+        Vec3i baseblockposition = ((Direction) state.getValue(BarrelBlock.FACING)).getNormal();
+        double d0 = (double) this.worldPosition.getX() + 0.5D + (double) baseblockposition.getX() / 2.0D;
+        double d1 = (double) this.worldPosition.getY() + 0.5D + (double) baseblockposition.getY() / 2.0D;
+        double d2 = (double) this.worldPosition.getZ() + 0.5D + (double) baseblockposition.getZ() / 2.0D;
+
+        this.level.playSound((Player) null, d0, d1, d2, soundEvent, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F);
     }
 }
