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

121 Zeilen
2.8 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.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
// CraftBukkit end
2011-01-29 22:50:29 +01:00
public class InventoryCrafting implements IInventory {
private ItemStack[] items;
2011-01-29 22:50:29 +01:00
private int b;
private Container c;
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
public CraftingRecipe currentRecipe;
public IInventory resultInventory;
2011-01-29 22:50:29 +01:00
public ItemStack[] getContents() {
return this.items;
2011-01-29 22:50:29 +01:00
}
public void onOpen(CraftHumanEntity who) {
transaction.add(who);
}
public InventoryType getInvType() {
return items.length == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
}
public void onClose(CraftHumanEntity who) {
transaction.remove(who);
}
public List<HumanEntity> getViewers() {
return transaction;
}
public InventoryHolder getOwner() {
return null; // TODO: Crafting grids don't really have an owner? Maybe they should?
}
2011-01-29 22:50:29 +01:00
// CraftBukkit end
public InventoryCrafting(Container container, int i, int j) {
int k = i * j;
this.items = new ItemStack[k];
2011-01-29 22:50:29 +01:00
this.c = container;
this.b = i;
}
public int getSize() {
return this.items.length;
2011-01-29 22:50:29 +01: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;
return this.getItem(k);
2011-01-29 22:50:29 +01:00
} else {
return null;
}
}
public String getName() {
2011-01-29 22:50:29 +01:00
return "Crafting";
}
public ItemStack splitStack(int i, int j) {
if (this.items[i] != null) {
2011-01-29 22:50:29 +01:00
ItemStack itemstack;
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 {
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;
}
}
public void setItem(int i, ItemStack itemstack) {
this.items[i] = itemstack;
2011-01-29 22:50:29 +01:00
this.c.a((IInventory) this);
}
public int getMaxStackSize() {
2011-01-29 22:50:29 +01:00
return 64;
}
public void update() {}
2011-01-29 22:50:29 +01:00
2011-09-15 02:23:52 +02:00
public boolean a(EntityHuman entityhuman) {
2011-01-29 22:50:29 +01:00
return true;
}
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
public void f() {}
2011-09-15 02:23:52 +02:00
2011-11-20 09:01:14 +01:00
public void g() {}
2011-01-29 22:50:29 +01:00
}