1
0
forked from xjboss/KCauldronX
KCauldronX/patches/net/minecraft/entity/item/EntityMinecartContainer.java.patch
2015-03-22 20:38:04 +03:00

79 lines
2.0 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java
@@ -9,12 +9,61 @@
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public abstract class EntityMinecartContainer extends EntityMinecart implements IInventory
{
private ItemStack[] minecartContainerItems = new ItemStack[36];
private boolean dropContentsWhenDead = true;
private static final String __OBFID = "CL_00001674";
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents()
+ {
+ return this.minecartContainerItems;
+ }
+
+ 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;
+ }
+
+ public void setMaxStackSize(int size)
+ {
+ maxStack = size;
+ }
+ // CraftBukkit end
+
public EntityMinecartContainer(World p_i1716_1_)
{
super(p_i1716_1_);
@@ -147,6 +196,13 @@
public void travelToDimension(int p_71027_1_)
{
+ // Spigot Start
+ for (HumanEntity human : new java.util.ArrayList<HumanEntity>(transaction))
+ {
+ human.closeInventory();
+ }
+
+ // Spigot End
this.dropContentsWhenDead = false;
super.travelToDimension(p_71027_1_);
}