[Bleeding] Implemented Inventory.{get,set}MaxStackSize(). Addresses BUKKIT-1076

- Custom inventories also respect this setting now.

By: Celtic Minstrel <celtic.minstrel.ca@some.place>
This commit is contained in:
CraftBukkit/Spigot 2012-03-14 10:00:54 -04:00
parent abfdfbf0e2
commit 5cb45990cc
2 changed files with 19 additions and 4 deletions

View file

@ -412,4 +412,12 @@ public class CraftInventory implements Inventory {
public InventoryHolder getHolder() {
return inventory.getOwner();
}
public int getMaxStackSize() {
return inventory.getMaxStackSize();
}
public void setMaxStackSize(int size) {
inventory.setMaxStackSize(size);
}
}

View file

@ -27,11 +27,11 @@ public class CraftInventoryCustom extends CraftInventory {
static class MinecraftInventory implements IInventory {
private ItemStack[] items;
private int maxStack = 64;
private int maxStack = MAX_STACK;
private List<HumanEntity> viewers;
private String title;
private InventoryType type;
private InventoryHolder owner; // TODO: Constructors to set this
private InventoryHolder owner;
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
this(owner, type.getDefaultSize(), type.getDefaultTitle());
@ -41,7 +41,7 @@ public class CraftInventoryCustom extends CraftInventory {
public MinecraftInventory(InventoryHolder owner, int size) {
this(owner, size, "Chest");
}
public MinecraftInventory(InventoryHolder owner, int size, String title) {
this.items = new ItemStack[size];
this.title = title;
@ -89,6 +89,9 @@ public class CraftInventoryCustom extends CraftInventory {
public void setItem(int i, ItemStack itemstack) {
items[i] = itemstack;
if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
itemstack.count = this.getMaxStackSize();
}
}
public String getName() {
@ -99,6 +102,10 @@ public class CraftInventoryCustom extends CraftInventory {
return maxStack;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
public void update() {}
public boolean a(EntityHuman entityhuman) {
@ -120,7 +127,7 @@ public class CraftInventoryCustom extends CraftInventory {
public List<HumanEntity> getViewers() {
return viewers;
}
public InventoryType getType() {
return type;
}