PaperMC/paper-server/nms-patches/net/minecraft/world/entity/vehicle/EntityMinecartContainer.patch
CraftBukkit/Spigot 65bc2541a3 Update to Minecraft 1.20.5
By: md_5 <git@md-5.net>
2024-04-24 01:15:00 +10:00

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