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:
@@ -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
|
||||||
|
|||||||
@@ -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,55 +56,81 @@ 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++;
|
||||||
|
}
|
||||||
|
|
||||||
if (!slot.isEmpty()) {
|
// We jump out of the loop above if we reach the maximum slot. If the maximum slot is empty,
|
||||||
int stackSize = upgrades.getItemInteractCount();
|
// 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 took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, true);
|
ItemStack slot = itemFilters.getStackInSlot(filterSlot);
|
||||||
|
|
||||||
if (took == null) {
|
if (!slot.isEmpty()) {
|
||||||
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
int stackSize = upgrades.getItemInteractCount();
|
||||||
network.getCraftingManager().schedule(slot, stackSize, compare);
|
|
||||||
}
|
|
||||||
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
|
|
||||||
took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, false);
|
|
||||||
|
|
||||||
if (took != null) {
|
ItemStack took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, true);
|
||||||
ItemHandlerHelper.insertItem(handler, took, false);
|
|
||||||
}
|
if (took == null) {
|
||||||
|
if (upgrades.hasUpgrade(ItemUpgrade.TYPE_CRAFTING)) {
|
||||||
|
network.getCraftingManager().schedule(slot, stackSize, compare);
|
||||||
|
}
|
||||||
|
} else if (ItemHandlerHelper.insertItem(handler, took, true).isEmpty()) {
|
||||||
|
took = network.extractItem(slot, Math.min(slot.getMaxStackSize(), stackSize), compare, false);
|
||||||
|
|
||||||
|
if (took != null) {
|
||||||
|
ItemHandlerHelper.insertItem(handler, took, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
|
||||||
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
|
|
||||||
|
|
||||||
if (stackInStorage != null) {
|
if (stack != null) {
|
||||||
int toExtract = Math.min(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), stackInStorage.amount);
|
FluidStack stackInStorage = network.getFluidStorageCache().getList().get(stack, compare);
|
||||||
|
|
||||||
FluidStack took = network.extractFluid(stack, toExtract, compare, true);
|
if (stackInStorage != null) {
|
||||||
|
int toExtract = Math.min(Fluid.BUCKET_VOLUME * upgrades.getItemInteractCount(), stackInStorage.amount);
|
||||||
|
|
||||||
if (took != null) {
|
FluidStack took = network.extractFluid(stack, toExtract, compare, true);
|
||||||
int filled = handler.fill(took, false);
|
|
||||||
|
|
||||||
if (filled > 0) {
|
if (took != null) {
|
||||||
took = network.extractFluid(stack, filled, compare, false);
|
int filled = handler.fill(took, false);
|
||||||
|
|
||||||
handler.fill(took, true);
|
if (filled > 0) {
|
||||||
|
took = network.extractFluid(stack, filled, compare, false);
|
||||||
|
|
||||||
break;
|
handler.fill(took, true);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
filterSlot++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user