mirror of
https://github.com/Ellpeck/PrettyPipes.git
synced 2025-01-09 22:57:44 +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())
|
if (remain.isEmpty())
|
||||||
return remain;
|
return remain;
|
||||||
}
|
}
|
||||||
|
System.out.println(remain);
|
||||||
// check craftable items
|
// check craftable items
|
||||||
return this.requestCraftedItem(destPipe, null, remain, new Stack<>(), equalityTypes).getLeft();
|
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);
|
amount -= this.getLockedAmount(location.getPos(), stack, ignoredLock, equalityTypes);
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return stack;
|
return stack;
|
||||||
var remain = stack.copy();
|
|
||||||
// make sure we only extract less than or equal to the requested amount
|
// make sure we only extract less than or equal to the requested amount
|
||||||
if (remain.getCount() < amount)
|
if (stack.getCount() < amount)
|
||||||
amount = remain.getCount();
|
amount = stack.getCount();
|
||||||
remain.shrink(amount);
|
|
||||||
for (int slot : location.getStackSlots(this.level, stack, equalityTypes)) {
|
for (int slot : location.getStackSlots(this.level, stack, equalityTypes)) {
|
||||||
// try to extract from that location's inventory and send the item
|
// try to extract from that location's inventory and send the item
|
||||||
var handler = location.getItemHandler(this.level);
|
var handler = location.getItemHandler(this.level);
|
||||||
|
@ -302,7 +301,8 @@ public class PipeNetwork extends SavedData implements GraphListener<BlockPos, Ne
|
||||||
break;
|
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) {
|
public PipeBlockEntity getPipe(BlockPos pos) {
|
||||||
|
|
|
@ -84,25 +84,11 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
var ensureItemOrder = module.get(Contents.TYPE).ensureItemOrder;
|
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 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()) {
|
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);
|
network.resolveNetworkLock(lock);
|
||||||
craft.ingredientsToRequest.remove(lock);
|
craft.ingredientsToRequest.remove(lock);
|
||||||
|
craft.travelingIngredients.add(lock.stack.copy());
|
||||||
craft.inProgress = true;
|
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();
|
network.endProfile();
|
||||||
|
@ -218,11 +204,10 @@ public class CraftingModuleItem extends ModuleItem {
|
||||||
var slot = tile.getModuleSlot(module);
|
var slot = tile.getModuleSlot(module);
|
||||||
var contents = module.get(Contents.TYPE);
|
var contents = module.get(Contents.TYPE);
|
||||||
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
var equalityTypes = ItemFilter.getEqualityTypes(tile);
|
||||||
var crafts = tile.getActiveCrafts();
|
var allCrafts = tile.getActiveCrafts();
|
||||||
var craft = crafts.stream()
|
var ourCrafts = allCrafts.stream().filter(c -> c.moduleSlot == slot && !c.getTravelingIngredient(stack, equalityTypes).isEmpty()).iterator();
|
||||||
.filter(c -> c.moduleSlot == slot && !c.getTravelingIngredient(stack, equalityTypes).isEmpty())
|
while (ourCrafts.hasNext()) {
|
||||||
.findAny().orElse(null);
|
var craft = ourCrafts.next();
|
||||||
if (craft != null) {
|
|
||||||
craft.travelingIngredients.remove(craft.getTravelingIngredient(stack, equalityTypes));
|
craft.travelingIngredients.remove(craft.getTravelingIngredient(stack, equalityTypes));
|
||||||
|
|
||||||
if (contents.insertSingles) {
|
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 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)
|
if (craft.canceled)
|
||||||
crafts.remove(craft);
|
allCrafts.remove(craft);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return stack;
|
return stack;
|
||||||
|
|
Loading…
Reference in a new issue