diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java index 0881d06..0111c62 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawersComp.java @@ -431,7 +431,7 @@ public class TileEntityDrawersComp extends TileEntityDrawers pooledCount = poolMax; if (pooledCount != oldCount) { - if (pooledCount != 0 || isLocked(LockAttribute.LOCK_POPULATED)) + if (pooledCount != 0 || TileEntityDrawersComp.this.isLocked(LockAttribute.LOCK_POPULATED)) markAmountDirty(); else { clear(); @@ -502,6 +502,11 @@ public class TileEntityDrawersComp extends TileEntityDrawers return true; } + @Override + public boolean isLocked (int slot, LockAttribute attr) { + return TileEntityDrawersComp.this.isLocked(attr); + } + @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 ed4c295..19a31f1 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java @@ -9,7 +9,9 @@ import appeng.api.storage.data.IAEItemStack; 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.ILockable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import com.jaquadro.minecraft.storagedrawers.storage.IUpgradeProvider; import net.minecraft.item.ItemStack; @@ -45,8 +47,15 @@ public class DrawerMEInventory implements IMEInventory if (!group.isDrawerEnabled(i)) continue; + if (group instanceof ILockable && ((ILockable) group).isLocked(LockAttribute.LOCK_EMPTY)) + continue; + IDrawer drawer = group.getDrawer(i); ItemStack itemProto = drawer.getStoredItemPrototype(); + + if (itemProto == null && drawer instanceof ILockable && ((ILockable) drawer).isLocked(LockAttribute.LOCK_EMPTY)) + continue; + if (itemProto == null) { itemProto = input.getItemStack(); if (drawer.canItemBeStored(itemProto)) { diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java b/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java index 91fa6b2..ba9d7e8 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/CompDrawerData.java @@ -1,12 +1,14 @@ package com.jaquadro.minecraft.storagedrawers.storage; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -public class CompDrawerData extends BaseDrawerData implements IVoidable, IShroudable +public class CompDrawerData extends BaseDrawerData implements IVoidable, IShroudable, ILockable { private static final ItemStack nullStack = new ItemStack((Item)null); @@ -114,4 +116,17 @@ public class CompDrawerData extends BaseDrawerData implements IVoidable, IShroud public boolean setIsShrouded (boolean state) { return central.setIsSlotShrouded(slot, state); } + + @Override + public boolean isLocked (LockAttribute attr) { + return central.isLocked(slot, attr); + } + + @Override + public boolean canLock (LockAttribute attr) { + return false; + } + + @Override + public void setLocked (LockAttribute attr, boolean isLocked) { } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java b/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java index db426f9..14dc6d8 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/DrawerData.java @@ -1,6 +1,7 @@ package com.jaquadro.minecraft.storagedrawers.storage; import com.jaquadro.minecraft.storagedrawers.api.event.DrawerPopulatedEvent; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; @@ -9,7 +10,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.MinecraftForge; -public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable +public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable, ILockable { private static final ItemStack nullStack = new ItemStack((Item)null); @@ -207,5 +208,18 @@ public class DrawerData extends BaseDrawerData implements IVoidable, IShroudable public boolean setIsShrouded (boolean state) { return storageProvider.setIsShrouded(slot, state); } + + @Override + public boolean isLocked (LockAttribute attr) { + return storageProvider.isLocked(slot, attr); + } + + @Override + public boolean canLock (LockAttribute attr) { + return false; + } + + @Override + public void setLocked (LockAttribute attr, boolean isLocked) { } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java b/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java index adec2b7..abcaff4 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/storage/ICentralInventory.java @@ -1,5 +1,6 @@ package com.jaquadro.minecraft.storagedrawers.storage; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -29,6 +30,8 @@ public interface ICentralInventory public boolean setIsSlotShrouded (int slot, boolean state); + public boolean isLocked (int slot, LockAttribute attr); + public void readFromNBT (int slot, NBTTagCompound tag); public void writeToNBT (int slot, NBTTagCompound tag);