Migrate alchemy table blocking to a boolean array
This commit is contained in:
parent
2db775346c
commit
1728ba7b83
|
@ -37,7 +37,7 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
||||||
public int ticksRequired = 1;
|
public int ticksRequired = 1;
|
||||||
|
|
||||||
public BlockPos connectedPos = BlockPos.ORIGIN;
|
public BlockPos connectedPos = BlockPos.ORIGIN;
|
||||||
public List<Integer> blockedSlots = new ArrayList<Integer>();
|
public boolean[] blockedSlots = new boolean[] { false, false, false, false, false, false };
|
||||||
|
|
||||||
public TileAlchemyTable()
|
public TileAlchemyTable()
|
||||||
{
|
{
|
||||||
|
@ -60,28 +60,14 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
||||||
return isSlave();
|
return isSlave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInputSlotAccessible(int slot)
|
public boolean isInputSlotAccessible(int slot) {
|
||||||
{
|
return !(slot < 6 && slot >= 0) || !blockedSlots[slot];
|
||||||
if (slot < 6 && slot >= 0)
|
|
||||||
{
|
|
||||||
return !blockedSlots.contains(slot);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void toggleInputSlotAccessible(int slot)
|
public void toggleInputSlotAccessible(int slot)
|
||||||
{
|
{
|
||||||
if (slot < 6 && slot >= 0)
|
if (slot < 6 && slot >= 0)
|
||||||
{
|
blockedSlots[slot] = !blockedSlots[slot];
|
||||||
if (blockedSlots.contains(slot))
|
|
||||||
{
|
|
||||||
blockedSlots.remove((Object) slot);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
blockedSlots.add(slot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -96,12 +82,9 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
||||||
burnTime = tag.getInteger("burnTime");
|
burnTime = tag.getInteger("burnTime");
|
||||||
ticksRequired = tag.getInteger("ticksRequired");
|
ticksRequired = tag.getInteger("ticksRequired");
|
||||||
|
|
||||||
blockedSlots.clear();
|
byte[] array = tag.getByteArray("blockedSlots");
|
||||||
int[] blockedSlotArray = tag.getIntArray("blockedSlots");
|
for (int i = 0; i < array.length; i++)
|
||||||
for (int blocked : blockedSlotArray)
|
blockedSlots[i] = array[i] != 0;
|
||||||
{
|
|
||||||
blockedSlots.add(blocked);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -118,13 +101,11 @@ public class TileAlchemyTable extends TileInventory implements ISidedInventory,
|
||||||
tag.setInteger("burnTime", burnTime);
|
tag.setInteger("burnTime", burnTime);
|
||||||
tag.setInteger("ticksRequired", ticksRequired);
|
tag.setInteger("ticksRequired", ticksRequired);
|
||||||
|
|
||||||
int[] blockedSlotArray = new int[blockedSlots.size()];
|
byte[] blockedSlotArray = new byte[blockedSlots.length];
|
||||||
for (int i = 0; i < blockedSlots.size(); i++)
|
for (int i = 0; i < blockedSlots.length; i++)
|
||||||
{
|
blockedSlotArray[i] = (byte) (blockedSlots[i] ? 1 : 0);
|
||||||
blockedSlotArray[i] = blockedSlots.get(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
tag.setIntArray("blockedSlots", blockedSlotArray);
|
tag.setByteArray("blockedSlots", blockedSlotArray);
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue