mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2025-01-09 14:47:43 +01:00
clean up some dead code
This commit is contained in:
parent
4d0e484c08
commit
eb15011d31
2 changed files with 12 additions and 27 deletions
|
@ -217,6 +217,7 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
if (remain.isEmpty())
|
||||
return remain;
|
||||
}
|
||||
System.out.println(remain);
|
||||
// check craftable items
|
||||
return this.requestCraftedItem(destPipe, null, remain, new Stack<>(), equalityTypes).getLeft();
|
||||
}
|
||||
|
@ -286,11 +287,9 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
amount -= this.getLockedAmount(location.getPos(), stack, ignoredLock, equalityTypes);
|
||||
if (amount <= 0)
|
||||
return stack;
|
||||
var remain = stack.copy();
|
||||
// make sure we only extract less than or equal to the requested amount
|
||||
if (remain.getCount() < amount)
|
||||
amount = remain.getCount();
|
||||
remain.shrink(amount);
|
||||
if (stack.getCount() < amount)
|
||||
amount = stack.getCount();
|
||||
for (int slot : location.getStackSlots(this.level, stack, equalityTypes)) {
|
||||
// try to extract from that location's inventory and send the item
|
||||
var handler = location.getItemHandler(this.level);
|
||||
|
@ -302,7 +301,8 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
|||
break;
|
||||
}
|
||||
}
|
||||
return remain;
|
||||
// we reduce the amount by what we managed to extract & insert in the for loop, so the amount down here will be what we couldn't
|
||||
return stack.copyWithCount(amount);
|
||||
}
|
||||
|
||||
public PipeBlockEntity getPipe(BlockPos pos) {
|
||||
|
|
|
@ -84,25 +84,11 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
var ensureItemOrder = module.get(Contents.TYPE).ensureItemOrder;
|
||||
// if we're ensuring the correct item order and the item is already on the way, don't do anything yet
|
||||
if (!ensureItemOrder || network.getPipeItemsOnTheWay(dest.getLeft()).findAny().isEmpty()) {
|
||||
var requestRemain = network.requestExistingItem(lock.location, tile.getBlockPos(), dest.getLeft(), lock, dest.getRight(), equalityTypes);
|
||||
network.requestExistingItem(lock.location, tile.getBlockPos(), dest.getLeft(), lock, dest.getRight(), equalityTypes);
|
||||
network.resolveNetworkLock(lock);
|
||||
craft.ingredientsToRequest.remove(lock);
|
||||
craft.travelingIngredients.add(lock.stack.copy());
|
||||
craft.inProgress = true;
|
||||
|
||||
var traveling = lock.stack.copy();
|
||||
traveling.shrink(requestRemain.getCount());
|
||||
craft.travelingIngredients.add(traveling);
|
||||
|
||||
// if we couldn't fit all items into the destination, create another request for the rest
|
||||
var remain = lock.stack.copy();
|
||||
remain.shrink(dest.getRight().getCount() - requestRemain.getCount());
|
||||
if (!remain.isEmpty()) {
|
||||
var remainRequest = new NetworkLock(lock.location, remain);
|
||||
// if we're ensuring item order, we need to insert the remaining request at the start so that it gets processed first
|
||||
var index = ensureItemOrder ? 0 : craft.ingredientsToRequest.size();
|
||||
craft.ingredientsToRequest.add(index, remainRequest);
|
||||
network.createNetworkLock(remainRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
network.endProfile();
|
||||
|
@ -218,11 +204,10 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
var slot = tile.getModuleSlot(module);
|
||||
var contents = module.get(Contents.TYPE);
|
||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||
var crafts = tile.getActiveCrafts();
|
||||
var craft = crafts.stream()
|
||||
.filter(c -> c.moduleSlot == slot && !c.getTravelingIngredient(stack, equalityTypes).isEmpty())
|
||||
.findAny().orElse(null);
|
||||
if (craft != null) {
|
||||
var allCrafts = tile.getActiveCrafts();
|
||||
var ourCrafts = allCrafts.stream().filter(c -> c.moduleSlot == slot && !c.getTravelingIngredient(stack, equalityTypes).isEmpty()).iterator();
|
||||
while (ourCrafts.hasNext()) {
|
||||
var craft = ourCrafts.next();
|
||||
craft.travelingIngredients.remove(craft.getTravelingIngredient(stack, equalityTypes));
|
||||
|
||||
if (contents.insertSingles) {
|
||||
|
@ -245,7 +230,7 @@ public class CraftingModuleItem extends ModuleItem {
|
|||
|
||||
// if we canceled the request and all input items are delivered (ie the machine actually got what it expected), remove it from the queue
|
||||
if (craft.canceled)
|
||||
crafts.remove(craft);
|
||||
allCrafts.remove(craft);
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
|
|
Loading…
Reference in a new issue