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)
- 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 Exporter now round-robins over every configured item or fluid to export instead of exporting them all at once (raoulvdberge)
- Updated Russian translation (kellixon)
### 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 type = IType.ITEMS;
private int filterSlot;
public NetworkNodeExporter(World world, BlockPos pos) {
super(world, pos);
}
@@ -54,8 +56,19 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
IItemHandler handler = WorldUtils.getItemHandler(getFacingTile(), getDirection().getOpposite());
if (handler != null) {
for (int i = 0; i < itemFilters.getSlots(); ++i) {
ItemStack slot = itemFilters.getStackInSlot(i);
while (filterSlot + 1 < itemFilters.getSlots() && itemFilters.getStackInSlot(filterSlot).isEmpty()) {
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()) {
int stackSize = upgrades.getItemInteractCount();
@@ -74,13 +87,29 @@ public class NetworkNodeExporter extends NetworkNode implements IComparable, ITy
}
}
}
}
filterSlot++;
}
} 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());
if (handler != null) {
for (FluidStack stack : fluidFilters.getFluids()) {
FluidStack stack = fluids[filterSlot];
if (stack != null) {
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);
handler.fill(took, true);
}
}
}
}
break;
}
}
}
}
}
filterSlot++;
}
}
}

View File

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