Start working on rewriting interfaces
This commit is contained in:
@@ -23,6 +23,7 @@ public interface IStorage {
|
|||||||
* @param stack The stack to push, do NOT modify this stack
|
* @param stack The stack to push, do NOT modify this stack
|
||||||
* @param simulate If we are simulating
|
* @param simulate If we are simulating
|
||||||
* @return null if the push was successful, or an ItemStack with the remainder
|
* @return null if the push was successful, or an ItemStack with the remainder
|
||||||
|
* @todo make it push(stack, size, simulate)
|
||||||
*/
|
*/
|
||||||
ItemStack push(ItemStack stack, boolean simulate);
|
ItemStack push(ItemStack stack, boolean simulate);
|
||||||
|
|
||||||
|
@@ -50,58 +50,19 @@ public class TileInterface extends TileMachine implements ICompareConfig {
|
|||||||
|
|
||||||
if (slot == null) {
|
if (slot == null) {
|
||||||
currentSlot++;
|
currentSlot++;
|
||||||
} else {
|
} else if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
||||||
if (ticks % RefinedStorageUtils.getSpeed(upgrades) == 0) {
|
int size = RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1;
|
||||||
int size = RefinedStorageUtils.hasUpgrade(upgrades, ItemUpgrade.TYPE_STACK) ? 64 : 1;
|
|
||||||
ItemStack push = ItemHandlerHelper.copyStackWithSize(slot, size);
|
|
||||||
ItemStack remainder = controller.push(push, false);
|
|
||||||
|
|
||||||
if (remainder == null) {
|
ItemStack pushing = ItemHandlerHelper.copyStackWithSize(slot, size);
|
||||||
importItems.extractItem(currentSlot, size, false);
|
|
||||||
} else {
|
if (controller.push(pushing, true) == null) {
|
||||||
importItems.extractItem(currentSlot, size - remainder.stackSize, false);
|
controller.push(pushing, false);
|
||||||
}
|
|
||||||
|
importItems.extractItem(currentSlot, size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 9; ++i) {
|
// @todo: export stuff
|
||||||
ItemStack wanted = exportSpecimenItems.getStackInSlot(i);
|
|
||||||
ItemStack got = exportItems.getStackInSlot(i);
|
|
||||||
|
|
||||||
if (wanted != null) {
|
|
||||||
boolean mayTake = false;
|
|
||||||
|
|
||||||
if (got != null) {
|
|
||||||
if (!RefinedStorageUtils.compareStack(wanted, got, compare)) {
|
|
||||||
exportItems.setStackInSlot(i, controller.push(got, false));
|
|
||||||
} else {
|
|
||||||
mayTake = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
mayTake = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mayTake) {
|
|
||||||
got = exportItems.getStackInSlot(i);
|
|
||||||
|
|
||||||
int needed = got == null ? wanted.stackSize : wanted.stackSize - got.stackSize;
|
|
||||||
|
|
||||||
if (needed > 0) {
|
|
||||||
ItemStack took = controller.take(wanted, needed, compare);
|
|
||||||
|
|
||||||
if (took != null) {
|
|
||||||
if (got == null) {
|
|
||||||
exportItems.setStackInSlot(i, took);
|
|
||||||
} else {
|
|
||||||
got.stackSize += took.stackSize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (got != null) {
|
|
||||||
exportItems.setStackInSlot(i, controller.push(got, false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Reference in New Issue
Block a user