Giant Inventory Refactor 2. Slots will only accept valid items

Moved logic out of Containers, the old filtered slots were not always the same
logic as the IInventory.

Moved ISidedInventory logic up to TileForestry and use InventoryAdapters
to override only the methods we need to.

Tested a ton but there will be some new issues given the scope.
This commit is contained in:
mezz committed 2014-12-31 04:22:33 -08:00
1 parent 2b3b590cf4
commit c54b7c40bb
124 files changed
+2414 -4259

No files matched your search

@@ -30,7 +30,6 @@ public class ItemImprinter extends ItemForestry {
public static class ImprinterInventory extends ItemInventory {
private final ItemStack[] inventoryStacks = new ItemStack[2];
private final short specimenSlot = 0;
private final short imprintedSlot = 1;
@@ -39,8 +38,8 @@ public class ItemImprinter extends ItemForestry {
private final EntityPlayer player;
public ImprinterInventory(EntityPlayer player) {
super(ItemImprinter.class);
public ImprinterInventory(EntityPlayer player, ItemStack itemStack) {
super(ItemImprinter.class, 2, itemStack);
this.player = player;
}
@@ -127,25 +126,6 @@ public class ItemImprinter extends ItemForestry {
inventoryStacks[specimenSlot] = null;
}
@Override
public ItemStack decrStackSize(int i, int j) {
if (inventoryStacks[i] == null)
return null;
ItemStack product;
if (inventoryStacks[i].stackSize <= j) {
product = inventoryStacks[i];
inventoryStacks[i] = null;
return product;
} else {
product = inventoryStacks[i].splitStack(j);
if (inventoryStacks[i].stackSize == 0)
inventoryStacks[i] = null;
return product;
}
}
@Override
public void markDirty() {
if (!Proxies.common.isSimulating(player.worldObj))
@@ -153,61 +133,14 @@ public class ItemImprinter extends ItemForestry {
tryImprint();
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack) {
inventoryStacks[i] = itemstack;
}
@Override
public ItemStack getStackInSlot(int i) {
return inventoryStacks[i];
}
@Override
public int getSizeInventory() {
return inventoryStacks.length;
}
@Override
public String getInventoryName() {
return "Imprinter";
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
if (inventoryStacks[slot] == null)
return null;
ItemStack toReturn = inventoryStacks[slot];
inventoryStacks[slot] = null;
return toReturn;
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
return true;
public boolean canSlotAccept(int slotIndex, ItemStack itemStack) {
return PluginApiculture.beeInterface.isMember(itemStack);
}
}