--- 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.ResourceKey;
+import net.minecraft.world.Container;
 import net.minecraft.world.Containers;
 import net.minecraft.world.InteractionHand;
 import net.minecraft.world.InteractionResult;
@@ -18,18 +19,79 @@
 import net.minecraft.world.level.Level;
 import net.minecraft.world.level.storage.loot.LootTable;
 
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.event.entity.EntityRemoveEvent;
+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 ResourceKey<LootTable> lootTable;
     public long lootTableSeed;
 
+    // Paper start - LootTable API
+    final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData();
+
+    @Override
+    public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData() {
+        return this.lootableData;
+    }
+    // Paper end - LootTable API
+    // 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
@@ -64,8 +126,7 @@
     }
 
     @Override
-    public void setChanged() {
-    }
+    public void setChanged() {}
 
     @Override
     public boolean stillValid(Player player) {
@@ -74,11 +135,18 @@
 
     @Override
     public void remove(Entity.RemovalReason reason) {
-        if (!this.level().isClientSide && reason.shouldDestroy()) {
-            Containers.dropContents(this.level(), this, this);
+        // CraftBukkit start - add Bukkit remove cause
+        this.remove(reason, null);
+    }
+
+    @Override
+    public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
+        // CraftBukkit end
+        if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) {
+            Containers.dropContents(this.level(), (Entity) this, (Container) this);
         }
 
-        super.remove(reason);
+        super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
     }
 
     @Override
@@ -101,16 +169,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.0, (double)f));
+        this.setDeltaMovement(this.getDeltaMovement().multiply((double) f, 0.0D, (double) f));
     }
 
     @Override
