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 compare = 0;
|
||||||
private int mode = 0;
|
private int mode = 0;
|
||||||
|
|
||||||
private int currentSlot = 0;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergyUsage() {
|
public int getEnergyUsage() {
|
||||||
return 2;
|
return 2;
|
||||||
@@ -29,42 +27,36 @@ public class TileImporter extends TileMachine implements ICompareSetting, IModeS
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMachine() {
|
public void updateMachine() {
|
||||||
TileEntity tile = worldObj.getTileEntity(pos.offset(getDirection()));
|
|
||||||
|
|
||||||
if (tile instanceof IInventory) {
|
|
||||||
IInventory connectedInventory = (IInventory) tile;
|
|
||||||
|
|
||||||
if (ticks % 5 == 0) {
|
if (ticks % 5 == 0) {
|
||||||
ItemStack slot = connectedInventory.getStackInSlot(currentSlot);
|
TileEntity connectedTile = worldObj.getTileEntity(pos.offset(getDirection()));
|
||||||
|
|
||||||
while ((slot = connectedInventory.getStackInSlot(currentSlot)) == null) {
|
if (connectedTile instanceof ISidedInventory) {
|
||||||
currentSlot++;
|
ISidedInventory sided = (ISidedInventory) connectedTile;
|
||||||
|
|
||||||
if (currentSlot > connectedInventory.getSizeInventory() - 1) {
|
int[] availableSlots = sided.getSlotsForFace(getDirection().getOpposite());
|
||||||
break;
|
|
||||||
|
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)) {
|
for (int i = 0; i < inventory.getSizeInventory(); ++i) {
|
||||||
if (connectedInventory instanceof ISidedInventory) {
|
ItemStack stack = inventory.getStackInSlot(i);
|
||||||
ISidedInventory sided = (ISidedInventory) connectedInventory;
|
|
||||||
|
|
||||||
if (sided.canExtractItem(currentSlot, slot.copy(), getDirection().getOpposite())) {
|
if (stack != null && canImport(stack)) {
|
||||||
if (getController().push(slot.copy())) {
|
if (getController().push(stack.copy())) {
|
||||||
connectedInventory.setInventorySlotContents(currentSlot, null);
|
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