--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
@@ -4,6 +4,7 @@
 import net.minecraft.core.NonNullList;
 import net.minecraft.nbt.CompoundTag;
 import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.Container;
 import net.minecraft.world.Containers;
 import net.minecraft.world.InteractionHand;
 import net.minecraft.world.InteractionResult;
@@ -16,19 +17,84 @@
 import net.minecraft.world.inventory.AbstractContainerMenu;
 import net.minecraft.world.item.ItemStack;
 import net.minecraft.world.level.Level;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.v1_20_R2.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
 
 public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
-    private NonNullList<ItemStack> itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
+
+    private NonNullList<ItemStack> itemStacks;
     @Nullable
     public ResourceLocation lootTable;
     public long lootTableSeed;
 
+    // Paper start
+    {
+        this.lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(new com.destroystokyo.paper.loottable.PaperContainerEntityLootableInventory(this));
+    }
+    @Override
+    public Entity getEntity() {
+        return this;
+    }
+
+    @Override
+    public com.destroystokyo.paper.loottable.PaperLootableInventoryData getLootableData() {
+        return this.lootableData;
+    }
+    // Paper end
+    // CraftBukkit start
+    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) {
+        this.transaction.add(who);
+    }
+
+    public void onClose(CraftHumanEntity who) {
+        this.transaction.remove(who);
+    }
+
+    public List<HumanEntity> getViewers() {
+        return this.transaction;
+    }
+
+    public InventoryHolder getOwner() {
+        org.bukkit.entity.Entity cart = this.getBukkitEntity();
+        if(cart instanceof InventoryHolder) return (InventoryHolder) cart;
+        return null;
+    }
+
+    @Override
+    public int getMaxStackSize() {
+        return this.maxStack;
+    }
+
+    public void setMaxStackSize(int size) {
+        this.maxStack = size;
+    }
+
+    @Override
+    public Location getLocation() {
+        return this.getBukkitEntity().getLocation();
+    }
+    // CraftBukkit end
+
     protected AbstractMinecartContainer(EntityType<?> type, Level world) {
         super(type, world);
+        this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
     }
 
     protected AbstractMinecartContainer(EntityType<?> type, double x, double y, double z, Level world) {
         super(type, world, x, y, z);
+        this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
     }
 
     @Override
@@ -63,8 +129,7 @@
     }
 
     @Override
-    public void setChanged() {
-    }
+    public void setChanged() {}
 
     @Override
     public boolean stillValid(Player player) {
@@ -74,7 +139,7 @@
     @Override
     public void remove(Entity.RemovalReason reason) {
         if (!this.level().isClientSide && reason.shouldDestroy()) {
-            Containers.dropContents(this.level(), this, this);
+            Containers.dropContents(this.level(), (Entity) this, (Container) this);
         }
 
         super.remove(reason);
@@ -83,12 +148,14 @@
     @Override
     protected void addAdditionalSaveData(CompoundTag nbt) {
         super.addAdditionalSaveData(nbt);
+        this.lootableData.saveNbt(nbt); // Paper
         this.addChestVehicleSaveData(nbt);
     }
 
     @Override
     protected void readAdditionalSaveData(CompoundTag nbt) {
         super.readAdditionalSaveData(nbt);
+        this.lootableData.loadNbt(nbt); // Paper
         this.readChestVehicleSaveData(nbt);
     }
 
@@ -100,16 +167,18 @@
     @Override
     protected void applyNaturalSlowdown() {
         float f = 0.98F;
+
         if (this.lootTable == null) {
             int i = 15 - AbstractContainerMenu.getRedstoneSignalFromContainer(this);
-            f += (float)i * 0.001F;
+
+            f += (float) i * 0.001F;
         }
 
         if (this.isInWater()) {
             f *= 0.95F;
         }
 
-        this.setDeltaMovement(this.getDeltaMovement().multiply((double)f, 0.0D, (double)f));
+        this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 0.0D, (double) f));
     }
 
     @Override
