Fix importer
This commit is contained in:
@@ -20,8 +20,6 @@ public class TileImporter extends TileMachine implements ICompareSetting, IModeS
|
||||
private int compare = 0;
|
||||
private int mode = 0;
|
||||
|
||||
private int currentSlot = 0;
|
||||
|
||||
@Override
|
||||
public int getEnergyUsage() {
|
||||
return 2;
|
||||
@@ -29,42 +27,36 @@ public class TileImporter extends TileMachine implements ICompareSetting, IModeS
|
||||
|
||||
@Override
|
||||
public void updateMachine() {
|
||||
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||
|
||||
if (tile instanceof IInventory) {
|
||||
IInventory connectedInventory = (IInventory) tile;
|
||||
|
||||
if (ticks % 5 == 0) {
|
||||
ItemStack slot = connectedInventory.getStackInSlot(currentSlot);
|
||||
TileEntity connectedTile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||
|
||||
while ((slot = connectedInventory.getStackInSlot(currentSlot)) == null) {
|
||||
currentSlot++;
|
||||
if (connectedTile instanceof ISidedInventory) {
|
||||
ISidedInventory sided = (ISidedInventory) connectedTile;
|
||||
|
||||
if (currentSlot > connectedInventory.getSizeInventory() - 1) {
|
||||
break;
|
||||
int[] availableSlots = sided.getSlotsForFace(getDirection().getOpposite());
|
||||
|
||||
for (int availableSlot : availableSlots) {
|
||||
ItemStack stack = sided.getStackInSlot(availableSlot);
|
||||
|
||||
if (stack != null && canImport(stack) && sided.canExtractItem(availableSlot, stack, getDirection().getOpposite())) {
|
||||
if (getController().push(stack.copy())) {
|
||||
sided.setInventorySlotContents(availableSlot, null);
|
||||
sided.markDirty();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (connectedTile instanceof IInventory) {
|
||||
IInventory inventory = (IInventory) connectedTile;
|
||||
|
||||
if (slot != null && canImport(slot)) {
|
||||
if (connectedInventory instanceof ISidedInventory) {
|
||||
ISidedInventory sided = (ISidedInventory) connectedInventory;
|
||||
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||
ItemStack stack = inventory.getStackInSlot(i);
|
||||
|
||||
if (sided.canExtractItem(currentSlot, slot.copy(), getDirection().getOpposite())) {
|
||||
if (getController().push(slot.copy())) {
|
||||
connectedInventory.setInventorySlotContents(currentSlot, null);
|
||||
if (stack != null && canImport(stack)) {
|
||||
if (getController().push(stack.copy())) {
|
||||
inventory.setInventorySlotContents(i, null);
|
||||
inventory.markDirty();
|
||||
}
|
||||
}
|
||||
} else if (getController().push(slot.copy())) {
|
||||
connectedInventory.setInventorySlotContents(currentSlot, null);
|
||||
}
|
||||
|
||||
connectedInventory.markDirty();
|
||||
}
|
||||
|
||||
currentSlot++;
|
||||
|
||||
if (currentSlot > connectedInventory.getSizeInventory() - 1) {
|
||||
currentSlot = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user