Interface fixes, still buggy when no storage is connected

This commit is contained in:
Raoul Van den Berge
2016-06-09 22:16:04 +02:00
parent 3cfb91bb02
commit d1fee9e766

View File

@@ -61,7 +61,38 @@ public class TileInterface extends TileMachine implements ICompareConfig {
}
}
// @todo: export stuff
for (int i = 0; i < 9; ++i) {
ItemStack wanted = exportSpecimenItems.getStackInSlot(i);
ItemStack got = exportItems.getStackInSlot(i);
if (wanted == null) {
if (got != null) {
exportItems.setStackInSlot(i, controller.push(got, got.stackSize, false));
}
} else {
int delta = got == null ? wanted.stackSize : (wanted.stackSize - got.stackSize);
if (delta > 0) {
ItemStack result = controller.take(wanted, delta, compare);
if (result != null) {
if (got == null) {
exportItems.setStackInSlot(i, result);
} else {
exportItems.getStackInSlot(i).stackSize += result.stackSize;
}
}
} else if (delta < 0) {
ItemStack remainder = controller.push(got, Math.abs(delta), false);
if (remainder == null) {
exportItems.extractItem(i, Math.abs(delta), false);
} else {
exportItems.extractItem(i, Math.abs(delta) - remainder.stackSize, false);
}
}
}
}
}
@Override