Paper/src/main/java/net/minecraft/server/InventoryLargeChest.java

120 Zeilen
3.2 KiB
Java

2011-01-29 22:50:29 +01:00
package net.minecraft.server;
// 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
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() {
ItemStack[] result = new ItemStack[this.getSize()];
2011-01-29 22:50:29 +01:00
for (int i = 0; i < result.length; i++) {
result[i] = this.getItem(i);
2011-01-29 22:50:29 +01:00
}
return result;
}
public void onOpen(CraftHumanEntity who) {
2012-02-29 22:31:04 +01:00
this.left.onOpen(who);
this.right.onOpen(who);
transaction.add(who);
}
public void onClose(CraftHumanEntity who) {
2012-02-29 22:31:04 +01:00
this.left.onClose(who);
this.right.onClose(who);
transaction.remove(who);
}
2012-02-29 22:31:04 +01:00
public List<HumanEntity> getViewers() {
return transaction;
}
2012-02-29 22:31:04 +01:00
public InventoryHolder getOwner() {
return null; // This method won't be called since CraftInventoryDoubleChest doesn't defer to here
}
public void setMaxStackSize(int size) {
this.left.setMaxStackSize(size);
this.right.setMaxStackSize(size);
}
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
}
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
}
public String getName() {
2011-01-29 22:50:29 +01:00
return this.a;
}
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
}
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);
}
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
}
}
public int getMaxStackSize() {
return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides
2011-01-29 22:50:29 +01: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
}
}