2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
|
|
|
|
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
|
2024-02-21 10:55:34 +01:00
|
|
|
@@ -18,6 +18,15 @@
|
2022-06-07 18:00:00 +02:00
|
|
|
import net.minecraft.world.item.ItemStack;
|
|
|
|
import net.minecraft.world.level.World;
|
2021-03-08 22:47:33 +01:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+// CraftBukkit start
|
|
|
|
+import java.util.List;
|
2016-05-10 13:47:39 +02:00
|
|
|
+import org.bukkit.Location;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
+import org.bukkit.entity.HumanEntity;
|
2024-02-21 10:55:34 +01:00
|
|
|
+import org.bukkit.event.entity.EntityRemoveEvent;
|
2014-11-25 22:32:16 +01:00
|
|
|
+import org.bukkit.inventory.InventoryHolder;
|
|
|
|
+// CraftBukkit end
|
2021-03-08 22:47:33 +01:00
|
|
|
+
|
2022-06-07 18:00:00 +02:00
|
|
|
public abstract class EntityMinecartContainer extends EntityMinecartAbstract implements ContainerEntity {
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
private NonNullList<ItemStack> itemStacks;
|
2024-02-21 10:55:34 +01:00
|
|
|
@@ -25,14 +34,55 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
public MinecraftKey lootTable;
|
2018-08-26 04:00:00 +02:00
|
|
|
public long lootTableSeed;
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
|
|
|
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
|
|
|
+ private int maxStack = MAX_STACK;
|
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
+ public List<ItemStack> getContents() {
|
2021-06-11 07:00:00 +02:00
|
|
|
+ return this.itemStacks;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onOpen(CraftHumanEntity who) {
|
|
|
|
+ transaction.add(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onClose(CraftHumanEntity who) {
|
|
|
|
+ transaction.remove(who);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<HumanEntity> getViewers() {
|
|
|
|
+ return transaction;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public InventoryHolder getOwner() {
|
|
|
|
+ org.bukkit.entity.Entity cart = getBukkitEntity();
|
|
|
|
+ if(cart instanceof InventoryHolder) return (InventoryHolder) cart;
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ @Override
|
|
|
|
+ public int getMaxStackSize() {
|
|
|
|
+ return maxStack;
|
|
|
|
+ }
|
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ public void setMaxStackSize(int size) {
|
|
|
|
+ maxStack = size;
|
|
|
|
+ }
|
2016-05-10 13:47:39 +02:00
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Location getLocation() {
|
|
|
|
+ return getBukkitEntity().getLocation();
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit end
|
2018-08-26 04:00:00 +02:00
|
|
|
+
|
2018-07-15 02:00:00 +02:00
|
|
|
protected EntityMinecartContainer(EntityTypes<?> entitytypes, World world) {
|
|
|
|
super(entitytypes, world);
|
2021-11-21 23:00:00 +01:00
|
|
|
- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
|
|
|
|
+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
2017-08-16 12:47:23 +02:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
protected EntityMinecartContainer(EntityTypes<?> entitytypes, double d0, double d1, double d2, World world) {
|
|
|
|
super(entitytypes, world, d0, d1, d2);
|
2021-11-21 23:00:00 +01:00
|
|
|
- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
|
|
|
|
+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2024-02-21 10:55:34 +01:00
|
|
|
@Override
|
|
|
|
@@ -76,11 +126,18 @@
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void remove(Entity.RemovalReason entity_removalreason) {
|
|
|
|
+ // CraftBukkit start - add Bukkit remove cause
|
|
|
|
+ this.remove(entity_removalreason, null);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) {
|
|
|
|
+ // CraftBukkit end
|
|
|
|
if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) {
|
|
|
|
InventoryUtils.dropContents(this.level(), (Entity) this, (IInventory) this);
|
|
|
|
}
|
|
|
|
|
|
|
|
- super.remove(entity_removalreason);
|
|
|
|
+ super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause
|
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@Override
|