From e050faaa905cc4fa52087f3cc5fc3c0c17f0ce32 Mon Sep 17 00:00:00 2001 From: slprime Date: Mon, 29 Jan 2024 21:07:18 +0200 Subject: [PATCH] fix fast DnD and recipe tooltip --- .../java/codechicken/nei/BookmarkPanel.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/java/codechicken/nei/BookmarkPanel.java b/src/main/java/codechicken/nei/BookmarkPanel.java index df7dec30..0ab98d07 100644 --- a/src/main/java/codechicken/nei/BookmarkPanel.java +++ b/src/main/java/codechicken/nei/BookmarkPanel.java @@ -217,7 +217,9 @@ public class BookmarkPanel extends PanelWidget { private static class RecipeTooltipRenderer { - public int slotIndex = 0; + public ItemStack stack = null; + public BookmarkRecipeId recipeId = null; + public GuiRecipe gui = null; public Runnable createRecipeGui = null; } @@ -1071,16 +1073,17 @@ public class BookmarkPanel extends PanelWidget { return; } - if (this.recipeTooltipRenderer == null || this.recipeTooltipRenderer.slotIndex != focused.slotIndex) { - + if (this.recipeTooltipRenderer == null || this.recipeTooltipRenderer.recipeId != meta.recipeId) { this.recipeTooltipRenderer = new RecipeTooltipRenderer(); - this.recipeTooltipRenderer.slotIndex = focused.slotIndex; + this.recipeTooltipRenderer.stack = this.realItems.get(focused.slotIndex); + this.recipeTooltipRenderer.recipeId = meta.recipeId; this.recipeTooltipRenderer.createRecipeGui = () -> { - final int slotIndex = this.recipeTooltipRenderer.slotIndex; - final BookmarkRecipeId recipeId = this.metadata.get(slotIndex).recipeId; - GuiRecipe gui = GuiCraftingRecipe - .createRecipeGui("recipeId", false, this.realItems.get(slotIndex), recipeId); + GuiRecipe gui = GuiCraftingRecipe.createRecipeGui( + "recipeId", + false, + this.recipeTooltipRenderer.stack, + this.recipeTooltipRenderer.recipeId); if (gui != null) { gui.initGui();