--- a/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
+++ b/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java
@@ -21,10 +_,11 @@
 import net.minecraft.world.phys.Vec3;
 
 public abstract class AbstractMinecartContainer extends AbstractMinecart implements ContainerEntity {
-    private NonNullList<ItemStack> itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
+    private NonNullList<ItemStack> itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
     @Nullable
     public ResourceKey<LootTable> lootTable;
     public long lootTableSeed;
+    private final com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData = new com.destroystokyo.paper.loottable.PaperLootableInventoryData(); // Paper - LootTable API
 
     protected AbstractMinecartContainer(EntityType<?> entityType, Level level) {
         super(entityType, level);
@@ -72,11 +_,18 @@
 
     @Override
     public void remove(Entity.RemovalReason reason) {
+        // CraftBukkit start - add Bukkit remove cause
+        this.remove(reason, null);
+    }
+
+    @Override
+    public void remove(Entity.RemovalReason reason, org.bukkit.event.entity.EntityRemoveEvent.Cause cause) {
+        // CraftBukkit end  - add Bukkit remove cause
         if (!this.level().isClientSide && reason.shouldDestroy()) {
             Containers.dropContents(this.level(), this, this);
         }
 
-        super.remove(reason);
+        super.remove(reason, cause); // CraftBukkit - add Bukkit remove cause
     }
 
     @Override
@@ -164,4 +_,50 @@
     public void clearItemStacks() {
         this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY);
     }
+
+    // Paper start - LootTable API
+    @Override
+    public com.destroystokyo.paper.loottable.PaperLootableInventoryData lootableData() {
+        return this.lootableData;
+    }
+    // Paper end - LootTable API
+
+    // CraftBukkit start
+    public java.util.List<org.bukkit.entity.HumanEntity> transaction = new java.util.ArrayList<>();
+    private int maxStack = MAX_STACK;
+
+    public java.util.List<net.minecraft.world.item.ItemStack> getContents() {
+        return this.itemStacks;
+    }
+
+    public void onOpen(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+        this.transaction.add(player);
+    }
+
+    public void onClose(org.bukkit.craftbukkit.entity.CraftHumanEntity player) {
+        this.transaction.remove(player);
+    }
+
+    public java.util.List<org.bukkit.entity.HumanEntity> getViewers() {
+        return this.transaction;
+    }
+
+    public org.bukkit.inventory.InventoryHolder getOwner() {
+        return this.getBukkitEntity() instanceof final org.bukkit.inventory.InventoryHolder inventoryHolder ? inventoryHolder : null;
+    }
+
+    @Override
+    public int getMaxStackSize() {
+        return this.maxStack;
+    }
+
+    public void setMaxStackSize(int size) {
+        this.maxStack = size;
+    }
+
+    @Override
+    public org.bukkit.Location getLocation() {
+        return this.getBukkitEntity().getLocation();
+    }
+    // CraftBukkit end
 }
