mirror of
https://github.com/GTNewHorizons/NotEnoughItems.git
synced 2026-11-16 18:54:45 +00:00
Optimize Chain Algorithm
This commit is contained in:
1 parent
c5c798c61a
commit
b16916dbe6
2 files changed
+6
-10
No files matched your search
@@ -269,27 +269,23 @@ public class BookmarkCraftingChain {
|
||||
return false;
|
||||
}
|
||||
|
||||
int shift = 0;
|
||||
int minRecipeIndex = 0;
|
||||
int minShift = 0x7fffff;
|
||||
int minShift = Integer.MAX_VALUE;
|
||||
|
||||
for (CraftingChainItem item : request.outputs.get(stackIndex)) {
|
||||
if (!request.initialItems.contains(item.recipeIndex) && item.factor > 0) {
|
||||
long ingrCount = calculateCount(request, request.inputs.get(item.stackIndex));
|
||||
long outputCount = calculateCount(request, request.outputs.get(item.stackIndex));
|
||||
long shift = (ingrCount - outputCount) / item.factor;
|
||||
|
||||
while ((outputCount + item.factor * shift) < ingrCount && shift < minShift) {
|
||||
shift++;
|
||||
}
|
||||
|
||||
if (shift < minShift) {
|
||||
minShift = shift;
|
||||
if (shift > 0 && shift < minShift) {
|
||||
minShift = (int) shift;
|
||||
minRecipeIndex = item.recipeIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (minShift < 0x7fffff) {
|
||||
if (minShift < Integer.MAX_VALUE) {
|
||||
request.multiplier.put(minRecipeIndex, request.multiplier.get(minRecipeIndex) + minShift);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1983,7 +1983,7 @@ public class BookmarkPanel extends PanelWidget {
|
||||
if (this.sortableItem != null) {
|
||||
this.sortableItem = null;
|
||||
this.mouseDownSlot = -1;
|
||||
grid.onGridChanged(); /* make sure grid redraws the new item */
|
||||
grid.onItemsChanged(); /* make sure grid redraws the new item */
|
||||
saveBookmarks();
|
||||
} else if (this.groupingItem != null) {
|
||||
final BookmarkGrid BGrid = (BookmarkGrid) grid;
|
||||
|
||||
Reference in new issue
Block a user