2011-01-29 22:50:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
import org.bukkit.inventory.InventoryHolder;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class InventoryLargeChest implements IInventory {
|
|
|
|
|
|
|
|
private String a;
|
2012-02-29 22:31:04 +01:00
|
|
|
public IInventory left; // CraftBukkit - private -> public
|
|
|
|
public IInventory right; // CraftBukkit - private -> public
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2012-02-29 19:56:35 +01:00
|
|
|
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
|
2012-02-29 22:31:04 +01:00
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public ItemStack[] getContents() {
|
2011-06-27 00:25:01 +02:00
|
|
|
ItemStack[] result = new ItemStack[this.getSize()];
|
2011-01-29 22:50:29 +01:00
|
|
|
for (int i = 0; i < result.length; i++) {
|
2011-06-27 00:25:01 +02:00
|
|
|
result[i] = this.getItem(i);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
2012-02-29 19:56:35 +01:00
|
|
|
|
|
|
|
public void onOpen(CraftHumanEntity who) {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.onOpen(who);
|
|
|
|
this.right.onOpen(who);
|
2012-02-29 19:56:35 +01:00
|
|
|
transaction.add(who);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onClose(CraftHumanEntity who) {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.onClose(who);
|
|
|
|
this.right.onClose(who);
|
2012-02-29 19:56:35 +01:00
|
|
|
transaction.remove(who);
|
|
|
|
}
|
2012-02-29 22:31:04 +01:00
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
public List<HumanEntity> getViewers() {
|
|
|
|
return transaction;
|
|
|
|
}
|
2012-02-29 22:31:04 +01:00
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
public InventoryHolder getOwner() {
|
|
|
|
return null; // Double chests technically have multiple owners, so there's no sensible way to pick one
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
|
|
|
|
this.a = s;
|
2011-09-15 02:23:52 +02:00
|
|
|
if (iinventory == null) {
|
|
|
|
iinventory = iinventory1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iinventory1 == null) {
|
|
|
|
iinventory1 = iinventory;
|
|
|
|
}
|
|
|
|
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left = iinventory;
|
|
|
|
this.right = iinventory1;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getSize() {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.left.getSize() + this.right.getSize();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public String getName() {
|
2011-01-29 22:50:29 +01:00
|
|
|
return this.a;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public ItemStack getItem(int i) {
|
2012-02-29 22:31:04 +01:00
|
|
|
return i >= this.left.getSize() ? this.right.getItem(i - this.left.getSize()) : this.left.getItem(i);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public ItemStack splitStack(int i, int j) {
|
2012-02-29 22:31:04 +01:00
|
|
|
return i >= this.left.getSize() ? this.right.splitStack(i - this.left.getSize(), j) : this.left.splitStack(i, j);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public ItemStack splitWithoutUpdate(int i) {
|
|
|
|
return i >= this.left.getSize() ? this.right.splitWithoutUpdate(i - this.left.getSize()) : this.left.splitWithoutUpdate(i);
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setItem(int i, ItemStack itemstack) {
|
2012-02-29 22:31:04 +01:00
|
|
|
if (i >= this.left.getSize()) {
|
|
|
|
this.right.setItem(i - this.left.getSize(), itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.setItem(i, itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getMaxStackSize() {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.left.getMaxStackSize();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void update() {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.update();
|
|
|
|
this.right.update();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 02:23:52 +02:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2012-02-29 22:31:04 +01:00
|
|
|
return this.left.a(entityhuman) && this.right.a(entityhuman);
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void f() {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.f();
|
|
|
|
this.right.f();
|
2011-09-15 02:23:52 +02:00
|
|
|
}
|
|
|
|
|
2011-11-20 09:01:14 +01:00
|
|
|
public void g() {
|
2012-02-29 22:31:04 +01:00
|
|
|
this.left.g();
|
|
|
|
this.right.g();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|