dont allocate parent tasks with empty priority

This commit is contained in:
Leijurv
2018-10-30 17:42:58 -07:00
parent e81b01a8f3
commit 91c6baead1
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -35,7 +35,7 @@ public class AquireCraftingItems extends QuantizedTaskNode implements IClaimProv
// they could provide us with quantity // they could provide us with quantity
int actualQuantity = (int) Math.ceil(quantity * 1.0D / amount); int actualQuantity = (int) Math.ceil(quantity * 1.0D / amount);
// so we could do the crafting recipe this many times // so we could do the crafting recipe this many times
// how good would that be?allocatedPriority // how good would that be?
return priority().value(actualQuantity); return priority().value(actualQuantity);
} }
@@ -38,13 +38,13 @@ public class ScarceParentPriorityAllocator {
int[] taken = new int[parents.size()]; int[] taken = new int[parents.size()];
while (true) { while (true) {
double bestRatio = Double.MIN_VALUE; double bestRatio = 0;
int bestParent = -1; int bestParent = -1;
int bestQuantity = -1; int bestQuantity = -1;
for (int i = 0; i < priorities.length; i++) { for (int i = 0; i < priorities.length; i++) {
for (int j = 1; j < quantity - filled; j++) { for (int j = 1; j < quantity - filled; j++) {
double ratio = priorities[i][j] / j; double ratio = priorities[i][j] / j;
if (ratio > bestRatio || bestRatio == Double.MIN_VALUE) { if (ratio > bestRatio) {
bestRatio = ratio; bestRatio = ratio;
bestParent = i; bestParent = i;
bestQuantity = j; bestQuantity = j;
@@ -52,7 +52,7 @@ public class ScarceParentPriorityAllocator {
} }
} }
if (bestParent == -1) { if (bestParent == -1 || bestRatio == 0) {
return new Tuple<>(totalPriority, taken); return new Tuple<>(totalPriority, taken);
} }
taken[bestParent] += bestQuantity; taken[bestParent] += bestQuantity;