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

130 Zeilen
3.5 KiB
Java

2011-01-29 22:50:29 +01:00
package net.minecraft.server;
// CraftBukkit start
import java.util.List;
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
// 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 java.util.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 org.bukkit.inventory.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
}
2012-11-06 13:05:28 +01:00
public boolean a(IInventory iinventory) {
return this.left == iinventory || this.right == iinventory;
}
public String getName() {
2013-03-13 23:33:27 +01:00
return this.left.c() ? this.left.getName() : (this.right.c() ? this.right.getName() : this.a);
}
public boolean c() {
return this.left.c() || this.right.c();
2011-01-29 22:50:29 +01: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
}
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
}
2013-03-13 23:33:27 +01:00
public boolean a(EntityHuman entityhuman) {
return this.left.a(entityhuman) && this.right.a(entityhuman);
2011-09-15 02:23:52 +02:00
}
2012-07-29 09:33:13 +02:00
public void startOpen() {
this.left.startOpen();
this.right.startOpen();
}
2013-03-13 23:33:27 +01:00
public void g() {
this.left.g();
this.right.g();
}
public boolean b(int i, ItemStack itemstack) {
return true;
2011-09-15 02:23:52 +02:00
}
2011-01-29 22:50:29 +01:00
}