2011-01-29 22:50:29 +01:00
|
|
|
package net.minecraft.server;
|
|
|
|
|
2012-02-29 13:56:35 -05: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 13:56:35 -05:00
|
|
|
public IInventory b; // CraftBukkit - private -> public
|
|
|
|
public IInventory c; // CraftBukkit - private -> public
|
2011-01-29 22:50:29 +01:00
|
|
|
|
|
|
|
// CraftBukkit start
|
2012-02-29 13:56:35 -05:00
|
|
|
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
|
|
|
|
|
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 13:56:35 -05:00
|
|
|
|
|
|
|
public void onOpen(CraftHumanEntity who) {
|
|
|
|
b.onOpen(who);
|
|
|
|
c.onOpen(who);
|
|
|
|
transaction.add(who);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onClose(CraftHumanEntity who) {
|
|
|
|
b.onClose(who);
|
|
|
|
c.onClose(who);
|
|
|
|
transaction.remove(who);
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<HumanEntity> getViewers() {
|
|
|
|
return transaction;
|
|
|
|
}
|
|
|
|
|
|
|
|
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 01:23:52 +01:00
|
|
|
if (iinventory == null) {
|
|
|
|
iinventory = iinventory1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iinventory1 == null) {
|
|
|
|
iinventory1 = iinventory;
|
|
|
|
}
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
this.b = iinventory;
|
|
|
|
this.c = iinventory1;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getSize() {
|
|
|
|
return this.b.getSize() + this.c.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) {
|
|
|
|
return i >= this.b.getSize() ? this.c.getItem(i - this.b.getSize()) : this.b.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) {
|
|
|
|
return i >= this.b.getSize() ? this.c.splitStack(i - this.b.getSize(), j) : this.b.splitStack(i, j);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setItem(int i, ItemStack itemstack) {
|
|
|
|
if (i >= this.b.getSize()) {
|
|
|
|
this.c.setItem(i - this.b.getSize(), itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
this.b.setItem(i, itemstack);
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getMaxStackSize() {
|
|
|
|
return this.b.getMaxStackSize();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void update() {
|
|
|
|
this.b.update();
|
|
|
|
this.c.update();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-09-15 01:23:52 +01:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
|
|
|
return this.b.a(entityhuman) && this.c.a(entityhuman);
|
|
|
|
}
|
|
|
|
|
2011-11-20 00:01:14 -08:00
|
|
|
public void f() {
|
|
|
|
this.b.f();
|
|
|
|
this.c.f();
|
2011-09-15 01:23:52 +01:00
|
|
|
}
|
|
|
|
|
2011-11-20 00:01:14 -08:00
|
|
|
public void g() {
|
|
|
|
this.b.g();
|
|
|
|
this.c.g();
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
}
|