diff --git a/src/main/java/crazypants/enderio/machine/invpanel/InventoryDatabaseServer.java b/src/main/java/crazypants/enderio/machine/invpanel/InventoryDatabaseServer.java index fee49478..e3c6b4e6 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/InventoryDatabaseServer.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/InventoryDatabaseServer.java @@ -13,10 +13,11 @@ import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; +import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; public class InventoryDatabaseServer extends InventoryDatabase { - private InventoryKey[] inventories; + private AbstractInventoryKey[] inventories; private int currentInventory; private ChangeLog changeLog; @@ -141,9 +142,14 @@ public class InventoryDatabaseServer extends InventoryDatabase> 12]; + AbstractInventoryKey key = db.inventories[idx >> 12]; count += key.itemCounts[idx & 4095]; } return count; @@ -214,7 +220,7 @@ public class InventoryDatabaseServer extends InventoryDatabase> 12; int slotIndex = idx & 4095; - InventoryKey key = db.inventories[niIndex]; + AbstractInventoryKey key = db.inventories[niIndex]; int amount = key.extractItem(db, this, slotIndex, niIndex, count); count -= amount; extracted += amount; @@ -223,17 +229,82 @@ public class InventoryDatabaseServer extends InventoryDatabase remaining) { + count = remaining; + } + + remaining -= count; + dsu.setStoredItemCount(remaining); + + updateCount(db, slot, niIndex, entry, remaining); + return count; + } + } + public interface ChangeLog { void entryChanged(ItemEntry entry); void databaseReset(); diff --git a/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java b/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java new file mode 100644 index 00000000..2ec1f76b --- /dev/null +++ b/src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java @@ -0,0 +1,35 @@ +package powercrystals.minefactoryreloaded.api; + +import net.minecraft.item.ItemStack; + +public interface IDeepStorageUnit { + + /** + * @return A populated ItemStack with stackSize for the full amount of + * materials in the DSU.
+ * May have a stackSize > getMaxStackSize(). May have a stackSize of + * 0 (indicating locked contents). + */ + ItemStack getStoredItemType(); + + /** + * Sets the total amount of the item currently being stored, or zero if all + * items are to be removed. + */ + void setStoredItemCount(int amount); + + /** + * Sets the type of the stored item and initializes the number of stored + * items to amount. + *

+ * Will overwrite any existing stored items. + */ + void setStoredItemType(ItemStack type, int amount); + + /** + * @return The maximum number of items the DSU can hold.
+ * May change based on the current type stored. + */ + int getMaxStoredCount(); + +}