mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
65bc2541a3
By: md_5 <git@md-5.net>
96 lines
3.1 KiB
Diff
96 lines
3.1 KiB
Diff
--- a/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
|
|
+++ b/net/minecraft/world/entity/vehicle/EntityMinecartContainer.java
|
|
@@ -19,6 +19,15 @@
|
|
import net.minecraft.world.level.World;
|
|
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 EntityMinecartContainer extends EntityMinecartAbstract implements ContainerEntity {
|
|
|
|
private NonNullList<ItemStack> itemStacks;
|
|
@@ -26,14 +35,55 @@
|
|
public ResourceKey<LootTable> lootTable;
|
|
public long lootTableSeed;
|
|
|
|
+ // 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) {
|
|
+ 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;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public int getMaxStackSize() {
|
|
+ return maxStack;
|
|
+ }
|
|
+
|
|
+ public void setMaxStackSize(int size) {
|
|
+ maxStack = size;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public Location getLocation() {
|
|
+ return getBukkitEntity().getLocation();
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+
|
|
protected EntityMinecartContainer(EntityTypes<?> entitytypes, World world) {
|
|
super(entitytypes, world);
|
|
- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
|
|
+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
|
}
|
|
|
|
protected EntityMinecartContainer(EntityTypes<?> entitytypes, double d0, double d1, double d2, World world) {
|
|
super(entitytypes, world, d0, d1, d2);
|
|
- this.itemStacks = NonNullList.withSize(36, ItemStack.EMPTY);
|
|
+ this.itemStacks = NonNullList.withSize(this.getContainerSize(), ItemStack.EMPTY); // CraftBukkit - SPIGOT-3513
|
|
}
|
|
|
|
@Override
|
|
@@ -77,11 +127,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
|
|
}
|
|
|
|
@Override
|