From df65da0c53c30115f0ac8c178cfb79b5193aaac9 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Tue, 5 May 2015 22:53:54 -0400 Subject: [PATCH] Fix AE and void upgrades through controllers too. --- build.gradle | 2 +- .../api/storage/attribute/IVoidable.java | 9 +++++++++ .../block/tile/TileEntityDrawersComp.java | 5 +++++ .../integration/ae2/DrawerMEInventory.java | 8 +++++--- .../storagedrawers/storage/CompDrawerData.java | 8 +++++++- .../storagedrawers/storage/DrawerData.java | 17 +++++++---------- .../storage/ICentralInventory.java | 2 ++ 7 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java diff --git a/build.gradle b/build.gradle index f4391302c..21b0b016f 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.4.1" +version = "1.7.10-1.4.2" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers" diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java b/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java new file mode 100644 index 000000000..9fc580635 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java @@ -0,0 +1,9 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +public interface IVoidable +{ + /** + * Gets whether or not the drawer has a voiding attribute. + */ + boolean isVoid (); +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java index d994ae6d5..fb9d35943 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java @@ -485,6 +485,11 @@ public int getItemCapacityForInventoryStack (int slot) { return getMaxCapacity(slot); } + @Override + public boolean isVoidSlot (int slot) { + return isVoid(); + } + @Override public void writeToNBT (int slot, NBTTagCompound tag) { ItemStack protoStack = getStoredItemPrototype(slot); diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java b/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java index 2743a877c..ed4c295a6 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java @@ -9,6 +9,7 @@ import appeng.api.storage.data.IItemList; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider; import net.minecraft.item.ItemStack; @@ -32,6 +33,8 @@ public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseAction if (itemProto != null) { if (drawer.canItemBeStored(input.getItemStack())) { itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; if (itemsLeft == 0) return null; } @@ -49,6 +52,8 @@ public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseAction if (drawer.canItemBeStored(itemProto)) { drawer.setStoredItem(itemProto, 0); itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; if (itemsLeft == 0) return null; } @@ -56,9 +61,6 @@ public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseAction } if (itemsLeft > 0) { - if (group instanceof IUpgradeProvider && ((IUpgradeProvider) group).isVoid()) - return null; - IAEItemStack overflow = AEApi.instance().storage().createItemStack(input.getItemStack()); overflow.setStackSize(itemsLeft); return overflow; diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java b/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java index fcd631bb7..072df816c 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java @@ -1,10 +1,11 @@ package com.jaquadro.minecraft.storagedrawers.storage; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class CompDrawerData extends BaseDrawerData +public class CompDrawerData extends BaseDrawerData implements IVoidable { private static final ItemStack nullStack = new ItemStack((Item)null); @@ -97,4 +98,9 @@ public void refresh () { reset(); refreshOreDictMatches(); } + + @Override + public boolean isVoid () { + return central.isVoidSlot(slot); + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java b/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java index e5b219cda..aea2820ad 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java @@ -1,21 +1,13 @@ package com.jaquadro.minecraft.storagedrawers.storage; -import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent; -import com.jaquadro.minecraft.storagedrawers.api.inventory.IInventoryAdapter; -import com.jaquadro.minecraft.storagedrawers.api.inventory.SlotType; -import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; -import com.jaquadro.minecraft.storagedrawers.inventory.InventoryStack; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.OreDictionary; -import java.util.ArrayList; -import java.util.List; - -public class DrawerData extends BaseDrawerData +public class DrawerData extends BaseDrawerData implements IVoidable { private static final ItemStack nullStack = new ItemStack((Item)null); @@ -198,5 +190,10 @@ protected void reset () { DrawerPopulatedEvent event = new DrawerPopulatedEvent(this); MinecraftForge.EVENT_BUS.post(event); } + + @Override + public boolean isVoid () { + return storageProvider.isVoid(slot); + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java b/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java index 0fc8f38df..5a27ea4b7 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java @@ -23,6 +23,8 @@ public interface ICentralInventory public int getItemCapacityForInventoryStack (int slot); + public boolean isVoidSlot (int slot); + public void readFromNBT (int slot, NBTTagCompound tag); public void writeToNBT (int slot, NBTTagCompound tag);