mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-19 05:31:32 +01:00
[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:
parent
abfdfbf0e2
commit
5cb45990cc
2 changed files with 19 additions and 4 deletions
|
@ -412,4 +412,12 @@ public class CraftInventory implements Inventory {
|
||||||
public InventoryHolder getHolder() {
|
public InventoryHolder getHolder() {
|
||||||
return inventory.getOwner();
|
return inventory.getOwner();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxStackSize() {
|
||||||
|
return inventory.getMaxStackSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxStackSize(int size) {
|
||||||
|
inventory.setMaxStackSize(size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||||
|
|
||||||
static class MinecraftInventory implements IInventory {
|
static class MinecraftInventory implements IInventory {
|
||||||
private ItemStack[] items;
|
private ItemStack[] items;
|
||||||
private int maxStack = 64;
|
private int maxStack = MAX_STACK;
|
||||||
private List<HumanEntity> viewers;
|
private List<HumanEntity> viewers;
|
||||||
private String title;
|
private String title;
|
||||||
private InventoryType type;
|
private InventoryType type;
|
||||||
private InventoryHolder owner; // TODO: Constructors to set this
|
private InventoryHolder owner;
|
||||||
|
|
||||||
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
|
public MinecraftInventory(InventoryHolder owner, InventoryType type) {
|
||||||
this(owner, type.getDefaultSize(), type.getDefaultTitle());
|
this(owner, type.getDefaultSize(), type.getDefaultTitle());
|
||||||
|
@ -41,7 +41,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||||
public MinecraftInventory(InventoryHolder owner, int size) {
|
public MinecraftInventory(InventoryHolder owner, int size) {
|
||||||
this(owner, size, "Chest");
|
this(owner, size, "Chest");
|
||||||
}
|
}
|
||||||
|
|
||||||
public MinecraftInventory(InventoryHolder owner, int size, String title) {
|
public MinecraftInventory(InventoryHolder owner, int size, String title) {
|
||||||
this.items = new ItemStack[size];
|
this.items = new ItemStack[size];
|
||||||
this.title = title;
|
this.title = title;
|
||||||
|
@ -89,6 +89,9 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||||
|
|
||||||
public void setItem(int i, ItemStack itemstack) {
|
public void setItem(int i, ItemStack itemstack) {
|
||||||
items[i] = itemstack;
|
items[i] = itemstack;
|
||||||
|
if (itemstack != null && this.getMaxStackSize() > 0 && itemstack.count > this.getMaxStackSize()) {
|
||||||
|
itemstack.count = this.getMaxStackSize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -99,6 +102,10 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||||
return maxStack;
|
return maxStack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setMaxStackSize(int size) {
|
||||||
|
maxStack = size;
|
||||||
|
}
|
||||||
|
|
||||||
public void update() {}
|
public void update() {}
|
||||||
|
|
||||||
public boolean a(EntityHuman entityhuman) {
|
public boolean a(EntityHuman entityhuman) {
|
||||||
|
@ -120,7 +127,7 @@ public class CraftInventoryCustom extends CraftInventory {
|
||||||
public List<HumanEntity> getViewers() {
|
public List<HumanEntity> getViewers() {
|
||||||
return viewers;
|
return viewers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryType getType() {
|
public InventoryType getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue