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.List;
|
|
|
|
|
|
|
|
import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
|
|
|
import org.bukkit.entity.HumanEntity;
|
|
|
|
import org.bukkit.event.inventory.InventoryType;
|
|
|
|
// CraftBukkit end
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public class InventoryCrafting implements IInventory {
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
private ItemStack[] items;
|
2011-01-29 22:50:29 +01:00
|
|
|
private int b;
|
|
|
|
private Container c;
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2012-07-22 08:18:00 +02:00
|
|
|
public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
2012-07-29 09:33:13 +02:00
|
|
|
public IRecipe currentRecipe;
|
2012-02-29 19:56:35 +01:00
|
|
|
public IInventory resultInventory;
|
2012-03-14 15:00:54 +01:00
|
|
|
private EntityHuman owner;
|
|
|
|
private int maxStack = MAX_STACK;
|
|
|
|
|
2011-01-29 22:50:29 +01:00
|
|
|
public ItemStack[] getContents() {
|
2011-06-27 00:25:01 +02:00
|
|
|
return this.items;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
2012-02-29 19:56:35 +01:00
|
|
|
|
|
|
|
public void onOpen(CraftHumanEntity who) {
|
|
|
|
transaction.add(who);
|
|
|
|
}
|
2012-03-14 15:00:54 +01:00
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
public InventoryType getInvType() {
|
|
|
|
return items.length == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void onClose(CraftHumanEntity who) {
|
|
|
|
transaction.remove(who);
|
|
|
|
}
|
2012-03-14 15:00:54 +01:00
|
|
|
|
2012-02-29 19:56:35 +01:00
|
|
|
public List<HumanEntity> getViewers() {
|
|
|
|
return transaction;
|
|
|
|
}
|
2012-03-14 15:00:54 +01:00
|
|
|
|
2012-07-22 08:18:00 +02:00
|
|
|
public org.bukkit.inventory.InventoryHolder getOwner() {
|
2012-03-14 15:00:54 +01:00
|
|
|
return owner.getBukkitEntity();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMaxStackSize(int size) {
|
|
|
|
maxStack = size;
|
|
|
|
resultInventory.setMaxStackSize(size);
|
|
|
|
}
|
|
|
|
|
|
|
|
public InventoryCrafting(Container container, int i, int j, EntityHuman player) {
|
|
|
|
this(container, i, j);
|
|
|
|
this.owner = player;
|
2012-02-29 19:56:35 +01:00
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
// CraftBukkit end
|
|
|
|
|
|
|
|
public InventoryCrafting(Container container, int i, int j) {
|
|
|
|
int k = i * j;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
this.items = new ItemStack[k];
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c = container;
|
|
|
|
this.b = i;
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getSize() {
|
|
|
|
return this.items.length;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public ItemStack getItem(int i) {
|
|
|
|
return i >= this.getSize() ? null : this.items[i];
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-02-23 03:37:56 +01:00
|
|
|
public ItemStack b(int i, int j) {
|
2011-01-29 22:50:29 +01:00
|
|
|
if (i >= 0 && i < this.b) {
|
|
|
|
int k = i + j * this.b;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
return this.getItem(k);
|
2011-01-29 22:50:29 +01:00
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public String getName() {
|
2012-03-01 11:49:23 +01:00
|
|
|
return "container.crafting";
|
|
|
|
}
|
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean c() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-03-01 11:49:23 +01:00
|
|
|
public ItemStack splitWithoutUpdate(int i) {
|
|
|
|
if (this.items[i] != null) {
|
|
|
|
ItemStack itemstack = this.items[i];
|
|
|
|
|
|
|
|
this.items[i] = null;
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-06-27 00:25:01 +02:00
|
|
|
public ItemStack splitStack(int i, int j) {
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.items[i] != null) {
|
2011-01-29 22:50:29 +01:00
|
|
|
ItemStack itemstack;
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
if (this.items[i].count <= j) {
|
|
|
|
itemstack = this.items[i];
|
|
|
|
this.items[i] = null;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c.a((IInventory) this);
|
|
|
|
return itemstack;
|
|
|
|
} else {
|
2011-04-20 19:05:14 +02:00
|
|
|
itemstack = this.items[i].a(j);
|
|
|
|
if (this.items[i].count == 0) {
|
|
|
|
this.items[i] = null;
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.c.a((IInventory) this);
|
|
|
|
return itemstack;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void setItem(int i, ItemStack itemstack) {
|
|
|
|
this.items[i] = itemstack;
|
2011-01-29 22:50:29 +01:00
|
|
|
this.c.a((IInventory) this);
|
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public int getMaxStackSize() {
|
2012-03-14 15:00:54 +01:00
|
|
|
return maxStack; // CraftBukkit
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|
|
|
|
|
2011-04-20 19:05:14 +02:00
|
|
|
public void update() {}
|
2011-01-29 22:50:29 +01:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public boolean a(EntityHuman entityhuman) {
|
2011-01-29 22:50:29 +01:00
|
|
|
return true;
|
|
|
|
}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2012-07-29 09:33:13 +02:00
|
|
|
public void startOpen() {}
|
2011-09-15 02:23:52 +02:00
|
|
|
|
2013-03-13 23:33:27 +01:00
|
|
|
public void g() {}
|
|
|
|
|
|
|
|
public boolean b(int i, ItemStack itemstack) {
|
|
|
|
return true;
|
|
|
|
}
|
2011-01-29 22:50:29 +01:00
|
|
|
}
|