From ac3fa7fcc21eadbf0122f1dca050f28f03aa1adf Mon Sep 17 00:00:00 2001 From: vfyjxf <2331007009@qq.com> Date: Tue, 5 Oct 2021 15:35:44 +0800 Subject: [PATCH] fix bug --- gradle.properties | 2 +- .../nee/client/NEEContainerDrawHandler.java | 90 ++++++++++--------- 2 files changed, 47 insertions(+), 45 deletions(-) diff --git a/gradle.properties b/gradle.properties index e2bd579..c4231d4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon=false mc_version=1.7.10 nei_version=2.1.6-GTNH ae2_version=rv3-beta-52-GTNH -mod_version=1.2.18 +mod_version=1.2.19 forge_version=10.13.4.1614 mod_group=com.github.vfyjxf.neenergistics mod_id=neenergistics diff --git a/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java b/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java index 6b3753e..f41a8e3 100644 --- a/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java +++ b/src/main/java/com/github/vfyjxf/nee/client/NEEContainerDrawHandler.java @@ -73,52 +73,54 @@ public class NEEContainerDrawHandler implements IContainerDrawHandler { public void renderSlotOverlay(GuiContainer gui, Slot slot) { if (gui instanceof GuiRecipe) { Minecraft mc = Minecraft.getMinecraft(); - final ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); - int i = scaledresolution.getScaledWidth(); - int j = scaledresolution.getScaledHeight(); - final int mouseX = Mouse.getX() * i / mc.displayWidth; - final int mouseY = j - Mouse.getY() * j / mc.displayHeight - 1; GuiRecipe guiRecipe = (GuiRecipe) gui; - GuiButton[] overlayButtons = null; - try { - overlayButtons = (GuiButton[]) this.overlayButtonsField.get(guiRecipe); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - if (overlayButtons != null) { - for (GuiButton button : overlayButtons) { - if (button.visible && button.enabled && GuiUtils.isMouseOverButton(button, mouseX, mouseY)) { - final int OVERLAY_BUTTON_ID_START = 4; - IRecipeHandler handler = null; - int recipesPerPage = -1; - try { - recipesPerPage = (int) this.recipesPerPageMethod.invoke(guiRecipe); - handler = (IRecipeHandler) this.handlerField.get(guiRecipe); - } catch (IllegalAccessException | InvocationTargetException e) { - e.printStackTrace(); - } - if (recipesPerPage >= 0 && handler != null) { - int recipeIndex = guiRecipe.page * recipesPerPage + button.id - OVERLAY_BUTTON_ID_START; - List ingredients = handler.getIngredientStacks(recipeIndex); - IngredientTracker tracker = createTracker(guiRecipe.firstGui, ingredients); + if (guiRecipe.firstGui instanceof GuiCraftingTerm || guiRecipe.firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(guiRecipe.firstGui)) { + final ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight); + int i = scaledresolution.getScaledWidth(); + int j = scaledresolution.getScaledHeight(); + final int mouseX = Mouse.getX() * i / mc.displayWidth; + final int mouseY = j - Mouse.getY() * j / mc.displayHeight - 1; + GuiButton[] overlayButtons = null; + try { + overlayButtons = (GuiButton[]) this.overlayButtonsField.get(guiRecipe); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + if (overlayButtons != null) { + for (GuiButton button : overlayButtons) { + if (button.visible && button.enabled && GuiUtils.isMouseOverButton(button, mouseX, mouseY)) { + final int OVERLAY_BUTTON_ID_START = 4; + IRecipeHandler handler = null; + int recipesPerPage = -1; + try { + recipesPerPage = (int) this.recipesPerPageMethod.invoke(guiRecipe); + handler = (IRecipeHandler) this.handlerField.get(guiRecipe); + } catch (IllegalAccessException | InvocationTargetException e) { + e.printStackTrace(); + } + if (recipesPerPage >= 0 && handler != null) { + int recipeIndex = guiRecipe.page * recipesPerPage + button.id - OVERLAY_BUTTON_ID_START; + List ingredients = handler.getIngredientStacks(recipeIndex); + IngredientTracker tracker = createTracker(guiRecipe.firstGui, ingredients); - for (int var1 = 0; var1 < ingredients.size(); var1++) { - PositionedStack stack = ingredients.get(var1); - Ingredient ingredient = tracker.getIngredients().get(var1); - Slot stackSlot = guiRecipe.slotcontainer.getSlotWithStack(stack, guiRecipe.getRecipePosition(recipeIndex).x, guiRecipe.getRecipePosition(recipeIndex).y); - if (stackSlot.equals(slot)) { - GuiContainer firstGui = guiRecipe.firstGui; - boolean renderAutoAbleItems = firstGui instanceof GuiCraftingTerm && ingredient.isCraftable() && ingredient.requiresToCraft(); - boolean renderCraftableItems = (firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui)) && ingredient.isCraftable(); - boolean renderMissingItems = firstGui instanceof GuiCraftingTerm && !ingredient.isCraftable() && ingredient.requiresToCraft(); - if (renderAutoAbleItems || renderCraftableItems) { - Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, - slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, - new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB()); - } else if (renderMissingItems) { - Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, - slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, - new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB()); + for (int var1 = 0; var1 < ingredients.size(); var1++) { + PositionedStack stack = ingredients.get(var1); + Ingredient ingredient = tracker.getIngredients().get(var1); + Slot stackSlot = guiRecipe.slotcontainer.getSlotWithStack(stack, guiRecipe.getRecipePosition(recipeIndex).x, guiRecipe.getRecipePosition(recipeIndex).y); + if (stackSlot.equals(slot)) { + GuiContainer firstGui = guiRecipe.firstGui; + boolean renderAutoAbleItems = firstGui instanceof GuiCraftingTerm && ingredient.isCraftable() && ingredient.requiresToCraft(); + boolean renderCraftableItems = (firstGui instanceof GuiPatternTerm || GuiUtils.isPatternTermExGui(firstGui)) && ingredient.isCraftable(); + boolean renderMissingItems = firstGui instanceof GuiCraftingTerm && !ingredient.isCraftable() && ingredient.requiresToCraft(); + if (renderAutoAbleItems || renderCraftableItems) { + Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, + slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, + new Color(0.0f, 0.0f, 1.0f, 0.4f).getRGB()); + } else if (renderMissingItems) { + Gui.drawRect(slot.xDisplayPosition, slot.yDisplayPosition, + slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, + new Color(1.0f, 0.0f, 0.0f, 0.4f).getRGB()); + } } } }