fix: 快捷键在 NEI 无配方界面时不再 NPE (#5) #6
@@ -0,0 +1,29 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Stratum <stratum@localhost>
|
||||
Date: Wed, 18 Nov 2026 17:20:43 +0800
|
||||
Subject: [PATCH] fix: hotkey does nothing when NEI has no recipe GUI to open
|
||||
(#5)
|
||||
|
||||
---
|
||||
src/main/java/com/kuba6000/mobsinfo/KeyBindingHandler.java | 5 ++++-
|
||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/src/main/java/com/kuba6000/mobsinfo/KeyBindingHandler.java b/src/main/java/com/kuba6000/mobsinfo/KeyBindingHandler.java
|
||||
index 6944524..4725637 100644
|
||||
--- a/src/main/java/com/kuba6000/mobsinfo/KeyBindingHandler.java
|
||||
+++ b/src/main/java/com/kuba6000/mobsinfo/KeyBindingHandler.java
|
||||
@@ -31,10 +31,13 @@ public class KeyBindingHandler {
|
||||
@SubscribeEvent
|
||||
public void onKey(InputEvent.KeyInputEvent evt) {
|
||||
if (mc.thePlayer != null && mc.theWorld != null && openGui.isPressed()) {
|
||||
- GuiCraftingRecipe gui = (GuiCraftingRecipe) GuiCraftingRecipe.createRecipeGui(
|
||||
+ Object created = GuiCraftingRecipe.createRecipeGui(
|
||||
MobHandler.getInstance()
|
||||
.getOverlayIdentifier(),
|
||||
false);
|
||||
+ // NEI returns null when no handler has any recipe (config not received yet, or Mob Handler disabled).
|
||||
+ if (!(created instanceof GuiCraftingRecipe)) return;
|
||||
+ GuiCraftingRecipe gui = (GuiCraftingRecipe) created;
|
||||
if (LoaderReference.InfernalMobs.isLoaded)
|
||||
gui.currenthandlers.add(new MobHandlerInfernal().addAllRecipes());
|
||||
gui.currenthandlers.add(new VillagerTradesHandler().addAllRecipes());
|
||||
Reference in new issue
Block a user