13
0
geforkt von Mirrors/Paper

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

- Custom inventories also respect this setting now.
Dieser Commit ist enthalten in:
Celtic Minstrel 2012-03-14 10:00:54 -04:00 committet von EvilSeph
Ursprung 66e067f373
Commit 5c8fd4995f
14 geänderte Dateien mit 105 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -7,10 +7,11 @@ public class ContainerEnchantTableInventory extends ContainerEnchantTableSubcont
ContainerEnchantTableInventory(ContainerEnchantTable containerenchanttable, String s, int i) {
super(s, i);
this.enchantTable = containerenchanttable;
super.setMaxStackSize(1); // CraftBukkit
}
public int getMaxStackSize() {
return 1;
return super.getMaxStackSize(); // CraftBukkit
}
public void update() {

Datei anzeigen

@ -18,6 +18,8 @@ public class ContainerEnchantTableSubcontainer implements IInventory {
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
public org.bukkit.entity.Player player;
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
@ -38,6 +40,10 @@ public class ContainerEnchantTableSubcontainer implements IInventory {
public InventoryHolder getOwner() {
return null; // TODO: Enchanting tables don't really have an owner? Maybe they should?
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public ContainerEnchantTableSubcontainer(String s, int i) {
@ -102,7 +108,7 @@ public class ContainerEnchantTableSubcontainer implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public void update() {

Datei anzeigen

@ -44,7 +44,8 @@ public class EntityMinecart extends Entity implements IInventory {
private double flyingY = 0.95;
private double flyingZ = 0.95;
public double maxSpeed = 0.4D;
public List<HumanEntity> transaction = new ArrayList<HumanEntity>(); // CraftBukkit
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
@ -67,6 +68,10 @@ public class EntityMinecart extends Entity implements IInventory {
if(cart instanceof InventoryHolder) return (InventoryHolder) cart;
return null;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public EntityMinecart(World world) {
@ -177,7 +182,7 @@ public class EntityMinecart extends Entity implements IInventory {
itemstack.count -= k;
// CraftBukkit - include enchantments in the new itemstack
EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, k, itemstack.getData(), itemstack.getEnchantments()));
EntityItem entityitem = new EntityItem(this.world, this.locX + (double) f, this.locY + (double) f1, this.locZ + (double) f2, new ItemStack(itemstack.id, k, itemstack.getData(), itemstack.getEnchantments()));
float f3 = 0.05F;
entityitem.motX = (double) ((float) this.random.nextGaussian() * f3);
@ -874,7 +879,7 @@ public class EntityMinecart extends Entity implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public void update() {}

Datei anzeigen

@ -34,13 +34,17 @@ public interface IInventory {
// CraftBukkit start
ItemStack[] getContents();
void onOpen(CraftHumanEntity who);
void onClose(CraftHumanEntity who);
List<HumanEntity> getViewers();
InventoryHolder getOwner();
void setMaxStackSize(int size);
int MAX_STACK = 64;
//CraftBukkit end
}

Datei anzeigen

@ -14,6 +14,8 @@ public class InventoryCraftResult implements IInventory {
private ItemStack[] items = new ItemStack[1];
// CraftBukkit start
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
}
@ -27,6 +29,10 @@ public class InventoryCraftResult implements IInventory {
public List<HumanEntity> getViewers() {
return new ArrayList<HumanEntity>();
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public InventoryCraftResult() {}
@ -70,7 +76,7 @@ public class InventoryCraftResult implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public void update() {}

Datei anzeigen

@ -20,7 +20,9 @@ public class InventoryCrafting implements IInventory {
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
public CraftingRecipe currentRecipe;
public IInventory resultInventory;
private EntityHuman owner;
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
}
@ -28,7 +30,7 @@ public class InventoryCrafting implements IInventory {
public void onOpen(CraftHumanEntity who) {
transaction.add(who);
}
public InventoryType getInvType() {
return items.length == 4 ? InventoryType.CRAFTING : InventoryType.WORKBENCH;
}
@ -36,13 +38,23 @@ public class InventoryCrafting implements IInventory {
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?
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;
}
// CraftBukkit end
@ -116,7 +128,7 @@ public class InventoryCrafting implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public void update() {}

Datei anzeigen

@ -45,6 +45,11 @@ public class InventoryLargeChest implements IInventory {
public 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);
}
// CraftBukkit end
public InventoryLargeChest(String s, IInventory iinventory, IInventory iinventory1) {
@ -90,7 +95,7 @@ public class InventoryLargeChest implements IInventory {
}
public int getMaxStackSize() {
return this.left.getMaxStackSize();
return Math.min(this.left.getMaxStackSize(), this.right.getMaxStackSize()); // CraftBukkit - check both sides
}
public void update() {

Datei anzeigen

@ -20,6 +20,7 @@ public class PlayerInventory implements IInventory {
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
@ -44,6 +45,10 @@ public class PlayerInventory implements IInventory {
public InventoryHolder getOwner() {
return this.player.getBukkitEntity();
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public PlayerInventory(EntityHuman entityhuman) {
@ -350,7 +355,7 @@ public class PlayerInventory implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public int a(Entity entity) {

Datei anzeigen

@ -23,6 +23,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory {
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = 1;
public void onOpen(CraftHumanEntity who) {
transaction.add(who);
@ -39,6 +40,10 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory {
public ItemStack[] getContents() {
return this.items;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public String getName() {
@ -228,7 +233,7 @@ public class TileEntityBrewingStand extends TileEntity implements IInventory {
}
public int getMaxStackSize() {
return 1;
return maxStack; // CraftBukkit
}
public boolean a(EntityHuman entityhuman) {

Datei anzeigen

@ -23,6 +23,7 @@ public class TileEntityChest extends TileEntity implements IInventory {
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
@ -39,6 +40,10 @@ public class TileEntityChest extends TileEntity implements IInventory {
public List<HumanEntity> getViewers() {
return transaction;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public TileEntityChest() {}
@ -132,7 +137,7 @@ public class TileEntityChest extends TileEntity implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public boolean a(EntityHuman entityhuman) {

Datei anzeigen

@ -17,6 +17,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
// CraftBukkit start
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
private int maxStack = MAX_STACK;
public ItemStack[] getContents() {
return this.items;
@ -33,6 +34,10 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
public List<HumanEntity> getViewers() {
return transaction;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public TileEntityDispenser() {}
@ -151,7 +156,7 @@ public class TileEntityDispenser extends TileEntity implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public boolean a(EntityHuman entityhuman) {

Datei anzeigen

@ -22,6 +22,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
// CraftBukkit start
private int lastTick = (int) (System.currentTimeMillis() / 50);
private int maxStack = MAX_STACK;
public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
public ItemStack[] getContents() {
@ -39,6 +40,10 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
public List<HumanEntity> getViewers() {
return transaction;
}
public void setMaxStackSize(int size) {
maxStack = size;
}
// CraftBukkit end
public TileEntityFurnace() {}
@ -134,7 +139,7 @@ public class TileEntityFurnace extends TileEntity implements IInventory {
}
public int getMaxStackSize() {
return 64;
return maxStack; // CraftBukkit
}
public boolean isBurning() {

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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;
}