Skip to content

Commit

Permalink
Merge remote-tracking branch 'slprime/bookmarks_groups_and_filter' in…
Browse files Browse the repository at this point in the history
…to dev
  • Loading branch information
Dream-Master committed Jan 16, 2024
2 parents 57db3fa + 4285632 commit d35e776
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
14 changes: 5 additions & 9 deletions src/main/java/codechicken/nei/BookmarkCraftingChain.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,27 +269,23 @@ private boolean calculateShift(CraftingChainRequest request, int stackIndex) {
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;
}
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/codechicken/nei/BookmarkPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1983,7 +1983,7 @@ public void mouseUp(int mousex, int mousey, int button) {
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;
Expand Down Expand Up @@ -2113,8 +2113,6 @@ public boolean pullBookmarkItems(int groupId, boolean onlyIngredients) {
final BookmarkGroup group = groupId >= 0 ? BGrid.groups.get(groupId) : null;
ItemStackMetadata meta;

System.out.println("onlyIngredients: " + onlyIngredients);

for (int idx = 0; idx < BGrid.realItems.size(); idx++) {
meta = BGrid.metadata.get(idx);

Expand Down

0 comments on commit d35e776

Please sign in to comment.