From 73f8567c94d5e0dfd1a8279e9a9216939b737a06 Mon Sep 17 00:00:00 2001 From: Justin Aquadro Date: Sun, 21 Jun 2015 02:47:21 -0400 Subject: [PATCH] Update inventory-input sorting preference to void->lock->normal->empty --- .../block/tile/TileEntityController.java | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java index 4555345..02633dc 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java @@ -7,6 +7,7 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked; 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 com.jaquadro.minecraft.storagedrawers.block.BlockSlave; import net.minecraft.block.Block; @@ -221,12 +222,18 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS private int[] sortInventorySlots () { int index = 0; + int normalIndex = 0; int emptyIndex = 0; int disabledIndex = 0; + int voidIndex = 0; + int lockedIndex = 0; int[] slotMap = new int[invSlotList.size()]; + int[] normalMap = new int[invSlotList.size()]; int[] emptyMap = new int[invSlotList.size()]; int[] disabledMap = new int[invSlotList.size()]; + int[] voidMap = new int[invSlotList.size()]; + int[] lockedMap = new int[invSlotList.size()]; for (int i = 0, n = invSlotList.size(); i < n; i++) { IDrawerGroup group = getGroupForInvSlot(i); @@ -243,12 +250,35 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IS } IDrawer drawer = group.getDrawer(drawerSlot); - if (!drawer.isEmpty()) - slotMap[index++] = i; - else + if (drawer.isEmpty()) { emptyMap[emptyIndex++] = i; + continue; + } + + if ((drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) || + (group instanceof IVoidable && ((IVoidable) group).isVoid())) { + voidMap[voidIndex++] = i; + continue; + } + + if ((drawer instanceof ILockable && ((ILockable) drawer).isLocked(LockAttribute.LOCK_POPULATED)) || + (group instanceof ILockable && ((ILockable) group).isLocked(LockAttribute.LOCK_POPULATED))) { + lockedMap[lockedIndex++] = i; + continue; + } + + normalMap[normalIndex++] = i; } + for (int i = 0; i < voidIndex; i++) + slotMap[index++] = voidMap[i]; + + for (int i = 0; i < lockedIndex; i++) + slotMap[index++] = lockedMap[i]; + + for (int i = 0; i < normalIndex; i++) + slotMap[index++] = normalMap[i]; + for (int i = 0; i < emptyIndex; i++) slotMap[index++] = emptyMap[i];