mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2024-12-22 15:39:22 +01:00
fixed crafting requests always returning the full crafted items, rather than the requested amount
This commit is contained in:
parent
21f2727b32
commit
fb59109d08
1 changed files with 25 additions and 17 deletions
|
@ -92,6 +92,11 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
}
|
||||
network.endProfile();
|
||||
} else if (craft.travelingIngredients.isEmpty()) {
|
||||
if (craft.resultStackRemain.isEmpty()) {
|
||||
// the result stack is empty from the start if this was a partial craft whose results shouldn't be delivered anywhere
|
||||
// (ie someone requested 3 sticks with ensureItemOrder, but the recipe always makes 4, so the 4th recipe has no destination)
|
||||
crafts.remove(craft);
|
||||
} else {
|
||||
// pull requested crafting results from the network once they are stored
|
||||
network.startProfile("crafting_results");
|
||||
var items = network.getOrderedNetworkItems(tile.getBlockPos());
|
||||
|
@ -115,6 +120,7 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getAllCraftables(ItemStack module, PipeBlockEntity tile) {
|
||||
|
@ -167,6 +173,7 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
var craftableCrafts = Mth.ceil(craftableAmount / (float) resultAmount);
|
||||
var toCraft = Math.min(craftableCrafts, requiredCrafts);
|
||||
|
||||
var leftOfRequest = stack.getCount();
|
||||
var allCrafts = new ArrayList<ActiveCraft>();
|
||||
// if we're ensuring item order, all items for a single recipe should be sent in order first before starting on the next one!
|
||||
for (var c = contents.ensureItemOrder ? toCraft : 1; c > 0; c--) {
|
||||
|
@ -185,10 +192,11 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
locks.addAll(ret.getLeft());
|
||||
allCrafts.addAll(ret.getRight());
|
||||
}
|
||||
var result = stack.copyWithCount(contents.ensureItemOrder ? resultAmount : resultAmount * toCraft);
|
||||
var activeCraft = new ActiveCraft(tile.getBlockPos(), slot, locks, destPipe, result);
|
||||
var crafted = contents.ensureItemOrder ? resultAmount : resultAmount * toCraft;
|
||||
var activeCraft = new ActiveCraft(tile.getBlockPos(), slot, locks, destPipe, stack.copyWithCount(Math.min(crafted, leftOfRequest)));
|
||||
tile.getActiveCrafts().add(activeCraft);
|
||||
allCrafts.add(activeCraft);
|
||||
leftOfRequest -= crafted;
|
||||
}
|
||||
|
||||
var remain = stack.copy();
|
||||
|
|
Loading…
Reference in a new issue