From b374f4088be4845b1cf1106e2123f1c226f8700e Mon Sep 17 00:00:00 2001 From: Boblet Date: Mon, 11 Aug 2025 11:52:48 +0200 Subject: [PATCH] agony --- src/main/java/com/hbm/main/MainRegistry.java | 3 +++ src/main/java/com/hbm/qmaw/QMAWLoader.java | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/hbm/main/MainRegistry.java b/src/main/java/com/hbm/main/MainRegistry.java index e5c2ca63d..20fc7b204 100644 --- a/src/main/java/com/hbm/main/MainRegistry.java +++ b/src/main/java/com/hbm/main/MainRegistry.java @@ -40,6 +40,7 @@ import com.hbm.lib.HbmWorld; import com.hbm.lib.RefStrings; import com.hbm.packet.PacketDispatcher; import com.hbm.potion.HbmPotion; +import com.hbm.qmaw.QMAWLoader; import com.hbm.saveddata.satellites.Satellite; import com.hbm.tileentity.TileMappings; import com.hbm.tileentity.bomb.TileEntityLaunchPadBase; @@ -253,6 +254,8 @@ public class MainRegistry { @EventHandler public void PreLoad(FMLPreInitializationEvent PreEvent) { CrashHelper.init(); + + QMAWLoader.registerModFileURL(FMLCommonHandler.instance().findContainerFor(RefStrings.MODID).getSource()); startupTime = System.currentTimeMillis(); configDir = PreEvent.getModConfigurationDirectory(); diff --git a/src/main/java/com/hbm/qmaw/QMAWLoader.java b/src/main/java/com/hbm/qmaw/QMAWLoader.java index 3bf265372..ee1596b3f 100644 --- a/src/main/java/com/hbm/qmaw/QMAWLoader.java +++ b/src/main/java/com/hbm/qmaw/QMAWLoader.java @@ -48,7 +48,7 @@ public class QMAWLoader implements IResourceManagerReloadListener { MainRegistry.logger.info("[QMAW] Loaded " + qmaw.size() + " manual entries! (" + (System.currentTimeMillis() - timestamp) + "ms)"); } - /** For the like 2 people who might consider making an NTM addon and want to include manual pages */ + /** For the like 2 people who might consider making an NTM addon and want to include manual pages. Requires the mod's actual JAR file as the parameter. */ public static void registerModFileURL(File file) { registeredModFiles.add(file); } @@ -56,12 +56,14 @@ public class QMAWLoader implements IResourceManagerReloadListener { /** Searches the asset folder for QMAW format JSON files and adds entries based on that */ public static void init() { - //the mod's file, assuming the mod is a file (not the case in a dev env, fuck!) + /*//the mod's file, assuming the mod is a file (not the case in a dev env, fuck!) //no fucking null check, if this fails then the entire game will sink along with the ship String path = QMAWLoader.class.getProtectionDomain().getCodeSource().getLocation().getPath(); // exclude .class in the case of a dev env MainRegistry.logger.info("[QMAW] Current running file: " + path); - if(!path.endsWith(".class")) registerModFileURL(new File(path)); // i am going to shit myself + if(!path.endsWith(".class")) registerModFileURL(new File(path)); // i am going to shit myself*/ // deactivated because it likely doesn't even fucking work + + // registering of the mod file now happens in the MainRegistry during preinit qmaw.clear(); triggers.clear(); @@ -153,7 +155,7 @@ public class QMAWLoader implements IResourceManagerReloadListener { /** Opens a resource pack folder, skips to the manual folder, then tries to dissect that */ public static void dissectFolder(File folder) { - File manualFolder = new File(folder, "/assets/manual"); + File manualFolder = new File(folder, "/assets/hbm/manual"); if(manualFolder.exists() && manualFolder.isDirectory()) dissectManualFolder(manualFolder); } @@ -180,6 +182,12 @@ public class QMAWLoader implements IResourceManagerReloadListener { public static void registerJson(String file, JsonObject json) { String name = json.get("name").getAsString(); + + if(QMAWLoader.qmaw.containsKey(name)) { + MainRegistry.logger.info("[QMAW] Skipping existing entry " + file); + return; + } + QuickManualAndWiki qmaw = new QuickManualAndWiki(name); if(json.has("icon")) {