Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly find the recipeId under mouse when using the search #465

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/codechicken/nei/BookmarkPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ public void loadBookmarksIfNeeded() {
itemStr);
}

} catch (IllegalArgumentException | JsonSyntaxException e) {
} catch (IllegalArgumentException | JsonSyntaxException | IllegalStateException e) {
NEIClientConfig.logger.error("Failed to load bookmarked ItemStack from json string:\n{}", itemStr);
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/codechicken/nei/ItemHistoryPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public void update() {

public void addItem(ItemStack stack) {
if (stack != null) {
ItemStack is = stack.copy();
is.stackSize = 1;
ItemStack is = StackInfo.loadFromNBT(StackInfo.itemStackToNBT(stack), 0);

grid.realItems.removeIf(historyStack -> StackInfo.equalItemAndNBT(historyStack, stack, true));
grid.realItems.add(0, is);
Expand Down
19 changes: 12 additions & 7 deletions src/main/java/codechicken/nei/recipe/GuiRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,11 @@ public int openTargetRecipe(BookmarkRecipeId recipeId) {
}

public List<PositionedStack> getFocusedRecipeIngredients() {
List<Integer> indices = getRecipeIndices();

for (int recipeIndex : getRecipeIndices()) {
if (recipeInFocus(recipeIndex)) {
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
final int recipeIndex = indices.get(refIndex);
if (recipeInFocus(refIndex, recipeIndex)) {
return handler.original.getIngredientStacks(recipeIndex);
}
}
Expand All @@ -554,9 +556,11 @@ public List<PositionedStack> getFocusedRecipeIngredients() {
}

public int prepareFocusedRecipeResultStackSize(ItemStack stackover) {
List<Integer> indices = getRecipeIndices();

for (int recipeIndex : getRecipeIndices()) {
if (recipeInFocus(recipeIndex)) {
for (int refIndex = 0; refIndex < indices.size(); refIndex++) {
final int recipeIndex = indices.get(refIndex);
if (recipeInFocus(refIndex, recipeIndex)) {
final PositionedStack result = handler.original.getResultStack(recipeIndex);
int stackSize = 0;

Expand All @@ -578,15 +582,16 @@ public int prepareFocusedRecipeResultStackSize(ItemStack stackover) {
return stackover.stackSize;
}

protected boolean recipeInFocus(int recipeIndex) {
protected boolean recipeInFocus(int refIndex, int recipeIndex) {
final PositionedStack result = handler.original.getResultStack(recipeIndex);
if (result != null && isMouseOver(result, recipeIndex)) {

if (result != null && isMouseOver(result, refIndex)) {
return true;
}

final List<PositionedStack> stacks = handler.original.getOtherStacks(recipeIndex);
for (PositionedStack stack : stacks) {
if (isMouseOver(stack, recipeIndex)) {
if (isMouseOver(stack, refIndex)) {
return true;
}
}
Expand Down