Compare commits

..
Author SHA1 Message Date
Wilhelm Schuster 166748c066 Make sure NEI plugins are loaded before processing keybindings (#375)
NEI plugins are initialized in a separate thread. If this takes too long,
the client tick handler might already be running checking the keybindings
in KeyManager while a plugin calls API.addKeyBind() which can lead to a
CME.

Reported in https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/13292
Thanks to @Denostrov for helping me track this down.
2023-05-07 16:39:08 +02:00
chill 28112a85e7 Readme: fix wording (#374) 2023-05-07 16:39:08 +02:00
miozune afba3f26f7 probably better way 2023-05-07 19:45:59 +09:00
miozune c47baaf019 updateBuildScript & spotlessApply 2023-05-07 19:27:12 +09:00
miozune 2207952e3b Separate logic to get detailed string of fluid amount 2023-05-07 19:26:10 +09:00
3 changed files with 6 additions and 41 deletions

No files matched your search

@@ -57,8 +57,7 @@ import codechicken.obfuscator.ObfuscationRun;
public class NEIClientConfig {
private static boolean mainNEIConfigLoaded;
private static boolean pluginNEIConfigLoaded;
private static boolean configLoaded;
private static boolean enabledOverride;
private static String worldPath;
@@ -464,9 +463,8 @@ public class NEIClientConfig {
}
public static void bootNEI(World world) {
if (mainNEIConfigLoaded) return;
if (configLoaded) return;
// main NEI config loading
ItemInfo.load(world);
GuiInfo.load();
RecipeInfo.load();
@@ -474,13 +472,10 @@ public class NEIClientConfig {
NEIController.load();
RecipeCatalysts.loadCatalystInfo();
mainNEIConfigLoaded = true;
new Thread("NEI Plugin Loader") {
@Override
public void run() {
logger.debug("Started NEI plugin loading");
ClassDiscoverer classDiscoverer = new ClassDiscoverer(
test -> test.startsWith("NEI") && test.endsWith("Config.class"),
IConfigureNEI.class);
@@ -498,14 +493,8 @@ public class NEIClientConfig {
}
}
// Set pluginNEIConfigLoaded here before posting the NEIConfigsLoadedEvent. This used to be the other
// way around, but apparently if your modpack includes 800 mods the event poster might not return in
// time and cause issues when loading a world for a second time as configLoaded is still false. This may
// cause issues in case one of the event handler calls the (non-thread-safe) NEI API. I don't expect any
// handler to do this, but who knows what modders have come up with...
pluginNEIConfigLoaded = true;
logger.debug("NEI plugin loading finished");
MinecraftForge.EVENT_BUS.post(new NEIConfigsLoadedEvent());
configLoaded = true;
}
}.start();
ItemSorter.loadConfig();
@@ -608,7 +597,7 @@ public class NEIClientConfig {
}
public static boolean isLoaded() {
return mainNEIConfigLoaded && pluginNEIConfigLoaded;
return configLoaded;
}
public static boolean loadHandlersFromJar() {
@@ -388,8 +388,6 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
// the value of the height field will be different from in other mouseover methods, which
// could be confusing...
if (recipeTabs.mouseScrolled(i)) return;
for (int recipe : getRecipeIndices()) if (handler.mouseScrolled(this, i, recipe)) return;
if (new Rectangle(guiLeft, guiTop, xSize, ySize).contains(GuiDraw.getMousePosition())) {
@@ -464,11 +462,11 @@ public abstract class GuiRecipe<H extends IRecipeHandler> extends GuiContainer i
if (page < 0) page = (handler.numRecipes() - 1) / getRecipesPerPage();
}
protected void nextType() {
private void nextType() {
setRecipePage(++recipetype);
}
protected void prevType() {
private void prevType() {
setRecipePage(--recipetype);
}
@@ -1,13 +1,9 @@
package codechicken.nei.recipe;
import static codechicken.lib.gui.GuiDraw.getMousePosition;
import java.awt.*;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.input.Keyboard;
import codechicken.nei.Button;
import codechicken.nei.NEIClientConfig;
import codechicken.nei.NEIClientUtils;
@@ -196,22 +192,4 @@ public class GuiRecipeTabs {
}
return false;
}
protected boolean mouseScrolled(int i) {
Point mPos = getMousePosition();
// Switch recipe handler tabs if either left shift is held or the tab
// bar is enable and the mouse cursor is positioned over said tab bar.
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT)
|| (NEIClientConfig.areJEIStyleTabsVisible() && (mPos.x >= area.x && mPos.x <= (area.x + area.width)
&& mPos.y >= area.y
&& mPos.y <= (area.y + area.height)))) {
if (i < 0) guiRecipe.nextType();
else guiRecipe.prevType();
return true;
}
return false;
}
}