The Exporter now round-robins over every configured item or fluid to export instead of exporting them all at once.

This commit is contained in:
raoulvdberge
2018-06-05 11:51:31 +02:00
parent 5cf75eceac
commit fb4c540809
3 changed files with 57 additions and 27 deletions

View File

@@ -19,6 +19,7 @@
- An empty blacklist now means: accept any item. An empty whitelist now means: don't accept any item (an empty whitelist USED to mean: accept any item) (raoulvdberge) - An empty blacklist now means: accept any item. An empty whitelist now means: don't accept any item (an empty whitelist USED to mean: accept any item) (raoulvdberge)
- Any mod can now add JSON Solderer recipes without requiring the API, by putting the JSONs in their assets directory in a "solderer_recipes" directory (raoulvdberge) - Any mod can now add JSON Solderer recipes without requiring the API, by putting the JSONs in their assets directory in a "solderer_recipes" directory (raoulvdberge)
- The Importer now skips over empty slots (raoulvdberge) - The Importer now skips over empty slots (raoulvdberge)
- The Exporter now round-robins over every configured item or fluid to export instead of exporting them all at once (raoulvdberge)
- Updated Russian translation (kellixon) - Updated Russian translation (kellixon)
### 1.5.34 ### 1.5.34

View File

@@ -36,6 +36,8 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE; private int compare = IComparer.COMPARE_NBT | IComparer.COMPARE_DAMAGE;
private int type = IType.ITEMS; private int type = IType.ITEMS;
private int filterSlot;
public NetworkNodeExporter(World world, BlockPos pos) { public NetworkNodeExporter(World world, BlockPos pos) {
super(world, pos); super(world, pos);
} }
@@ -54,8 +56,19 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
IItemHandler handler = WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite()); IItemHandler handler = WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) { if (handler != null) {
for (int i = 0; i < itemFilters.getSlots(); ++i) { while (filterSlot + 1 < itemFilters.getSlots() && itemFilters.getStackInSlot(filterSlot).isEmpty()) {
ItemStack slot = itemFilters.getStackInSlot(i); filterSlot++;
}
// We jump out of the loop above if we reach the maximum slot. If the maximum slot is empty,
// we waste a tick with doing nothing because it's empty. Hence this check. If we are at the last slot
// and it's empty, go back to slot 0.
// We also handle if we exceeded the maximum slot in general.
if ((filterSlot == itemFilters.getSlots() - 1 && itemFilters.getStackInSlot(filterSlot).isEmpty()) || (filterSlot >= itemFilters.getSlots())) {
filterSlot = 0;
}
ItemStack slot = itemFilters.getStackInSlot(filterSlot);
if (!slot.isEmpty()) { if (!slot.isEmpty()) {
int stackSize = upgrades.getItemInteractCount(); int stackSize = upgrades.getItemInteractCount();
@@ -74,13 +87,29 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
} }
} }
} }
}
filterSlot++;
} }
} else if (type == IType.FLUIDS) { } else if (type == IType.FLUIDS) {
FluidStack[] fluids = fluidFilters.getFluids();
while (filterSlot + 1 < fluids.length && fluids[filterSlot] == null) {
filterSlot++;
}
// We jump out of the loop above if we reach the maximum slot. If the maximum slot is empty,
// we waste a tick with doing nothing because it's empty. Hence this check. If we are at the last slot
// and it's empty, go back to slot 0.
// We also handle if we exceeded the maximum slot in general.
if ((filterSlot == fluids.length - 1 && fluids[filterSlot] == null) || (filterSlot >= fluids.length)) {
filterSlot = 0;
}
IFluidHandler handler = WorldUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite()); IFluidHandler handler = WorldUtils.getFluidHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) { if (handler != null) {
for (FluidStack stack : fluidFilters.getFluids()) { FluidStack stack = fluids[filterSlot];
if (stack != null) { if (stack != null) {
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare); FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
@@ -96,13 +125,12 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
took = network.extractFluid(stack, filled, compare, false); took = network.extractFluid(stack, filled, compare, false);
handler.fill(took, true); handler.fill(took, true);
}
}
}
}
break; filterSlot++;
}
}
}
}
}
} }
} }
} }

View File

@@ -108,6 +108,7 @@ public class NetworkNodeImporter extends NetworkNode implements IComparable, IFi
if (remainder != null) { if (remainder != null) {
toDrain.amount -= remainder.amount; toDrain.amount -= remainder.amount;
} }
handler.drain(toDrain, true); handler.drain(toDrain, true);
} }
} }