From 61120ed30b50fe6740eb8d6ce3ffac3583072463 Mon Sep 17 00:00:00 2001 From: gigabit101 Date: Mon, 7 Sep 2015 20:48:35 +0100 Subject: [PATCH] Added Ae2 and Logistic pipe support to Quantum Chest --- .../api/IDeepStorageUnit.java | 35 +++++++++++++++++++ .../client/gui/GuiQuantumChest.java | 4 +-- .../techreborn/tiles/TileQuantumChest.java | 27 +++++++++++++- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 src/main/java/powercrystals/minefactoryreloaded/api/IDeepStorageUnit.java 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 000000000..2ec1f76b3 --- /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(); + +} diff --git a/src/main/java/techreborn/client/gui/GuiQuantumChest.java b/src/main/java/techreborn/client/gui/GuiQuantumChest.java index 4571d0ba1..d68d4c4db 100644 --- a/src/main/java/techreborn/client/gui/GuiQuantumChest.java +++ b/src/main/java/techreborn/client/gui/GuiQuantumChest.java @@ -39,8 +39,8 @@ public class GuiQuantumChest extends GuiContainer { I18n.format("container.inventory", new Object[0]), 8, this.ySize - 96 + 2, 4210752); this.fontRendererObj.drawString("Amount", 10, 20, 16448255); - if (tile.storedItem != null) - this.fontRendererObj.drawString(tile.storedItem.stackSize + "", 10, + if (tile.storedItem != null && tile.getStackInSlot(1) !=null) + this.fontRendererObj.drawString(tile.storedItem.stackSize + tile.getStackInSlot(1).stackSize + "", 10, 30, 16448255); } } diff --git a/src/main/java/techreborn/tiles/TileQuantumChest.java b/src/main/java/techreborn/tiles/TileQuantumChest.java index 28d2abdc6..7eff27a24 100644 --- a/src/main/java/techreborn/tiles/TileQuantumChest.java +++ b/src/main/java/techreborn/tiles/TileQuantumChest.java @@ -8,6 +8,7 @@ import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; +import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; import techreborn.init.ModBlocks; import techreborn.util.Inventory; import techreborn.util.ItemUtils; @@ -15,7 +16,7 @@ import techreborn.util.ItemUtils; import java.util.List; public class TileQuantumChest extends TileMachineBase implements IInventory, - IWrenchable { + IWrenchable, IDeepStorageUnit { // Slot 0 = Input // Slot 1 = Output @@ -245,4 +246,28 @@ public class TileQuantumChest extends TileMachineBase implements IInventory, info.add(size + " " + name); } + + @Override + public ItemStack getStoredItemType() { + return this.storedItem; + } + + @Override + public void setStoredItemCount(int amount) { + this.storedItem.stackSize = 0; + this.storedItem.stackSize += (amount); + this.markDirty(); + } + + @Override + public void setStoredItemType(ItemStack type, int amount) { + this.storedItem = type; + this.storedItem.stackSize = amount; + this.markDirty(); + } + + @Override + public int getMaxStoredCount() { + return this.storage; + } }