From 6aecc447923679363a98e4bc5f89faaaed970f6e Mon Sep 17 00:00:00 2001 From: a Date: Tue, 10 Sep 2024 16:46:13 +0800 Subject: [PATCH] fix config missing "remove research category" issue --- .../thaumcraftfix/ThaumcraftFix.java | 357 +++++++++--------- .../common/ThaumcraftFixConfig.java | 8 + .../common/research/ResearchConfigParser.java | 15 + 3 files changed, 201 insertions(+), 179 deletions(-) diff --git a/src/main/java/thecodex6824/thaumcraftfix/ThaumcraftFix.java b/src/main/java/thecodex6824/thaumcraftfix/ThaumcraftFix.java index 49e8b60..14e6f67 100644 --- a/src/main/java/thecodex6824/thaumcraftfix/ThaumcraftFix.java +++ b/src/main/java/thecodex6824/thaumcraftfix/ThaumcraftFix.java @@ -1,21 +1,21 @@ /** - * Thaumcraft Fix - * Copyright (c) 2024 TheCodex6824. - * - * This file is part of Thaumcraft Fix. - * - * Thaumcraft Fix is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Thaumcraft Fix is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with Thaumcraft Fix. If not, see . + * Thaumcraft Fix + * Copyright (c) 2024 TheCodex6824. + *

+ * This file is part of Thaumcraft Fix. + *

+ * Thaumcraft Fix is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * Thaumcraft Fix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public License + * along with Thaumcraft Fix. If not, see . */ package thecodex6824.thaumcraftfix; @@ -88,7 +88,7 @@ import thecodex6824.thaumcraftfix.common.world.AuraFinalizerWorldGenerator; @Mod(modid = ThaumcraftFixApi.MODID, name = "Thaumcraft Fix", version = ThaumcraftFix.VERSION, useMetadata = true, -certificateFingerprint = "@FINGERPRINT@") + certificateFingerprint = "@FINGERPRINT@") @EventBusSubscriber public class ThaumcraftFix { @@ -98,7 +98,7 @@ public class ThaumcraftFix { public static ThaumcraftFix instance; @SidedProxy(modId = ThaumcraftFixApi.MODID, serverSide = "thecodex6824.thaumcraftfix.ServerProxy", - clientSide = "thecodex6824.thaumcraftfix.ClientProxy") + clientSide = "thecodex6824.thaumcraftfix.ClientProxy") public static IProxy proxy; private Logger logger; @@ -106,208 +106,207 @@ public class ThaumcraftFix { @EventHandler public void construction(FMLConstructionEvent event) { - proxy.construction(); + proxy.construction(); } @EventHandler public void preInit(FMLPreInitializationEvent event) { - logger = event.getModLog(); - ThaumcraftFixApiBridge.setImplementation(new DefaultApiImplementation()); - CapabilityManager.INSTANCE.register(IOriginalAuraInfo.class, new IStorage() { - @Override - public void readNBT(Capability capability, IOriginalAuraInfo instance, EnumFacing side, NBTBase nbt) { - if (!(instance instanceof OriginalAuraInfo) || !(nbt instanceof NBTTagCompound)) - throw new UnsupportedOperationException("Can't deserialize non-API implementation"); - - ((OriginalAuraInfo) instance).deserializeNBT((NBTTagCompound) nbt); - } - - @Override - @Nullable - public NBTBase writeNBT(Capability capability, IOriginalAuraInfo instance, EnumFacing side) { - if (!(instance instanceof OriginalAuraInfo)) - throw new UnsupportedOperationException("Can't serialize non-API implementation"); - - return ((OriginalAuraInfo) instance).serializeNBT(); - } - }, OriginalAuraInfo::new); - ResearchApi.registerScanParser(new ScanParserBlock(), 1000); - ResearchApi.registerScanParser(new ScanParserItem(), 1000); - ResearchApi.registerScanParser(new ScanParserItemExtended(), 1000); - ResearchApi.registerScanParser(new ScanParserEntity(), 1000); - ResearchApi.registerResearchEntrySource(Paths.get("config", ThaumcraftFixApi.MODID, "entries")); - ResearchApi.registerResearchPatchSource(Paths.get("config", ThaumcraftFixApi.MODID, "patches"), 1000); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/alchemy.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/artifice.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/auromancy.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/basics.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/eldritch.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/golemancy.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/infusion.json"), -1); - ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/scans.json"), -1); + logger = event.getModLog(); + ThaumcraftFixApiBridge.setImplementation(new DefaultApiImplementation()); + CapabilityManager.INSTANCE.register(IOriginalAuraInfo.class, new IStorage() { + @Override + public void readNBT(Capability capability, IOriginalAuraInfo instance, EnumFacing side, NBTBase nbt) { + if (!(instance instanceof OriginalAuraInfo) || !(nbt instanceof NBTTagCompound)) + throw new UnsupportedOperationException("Can't deserialize non-API implementation"); + + ((OriginalAuraInfo) instance).deserializeNBT((NBTTagCompound) nbt); + } + + @Override + @Nullable + public NBTBase writeNBT(Capability capability, IOriginalAuraInfo instance, EnumFacing side) { + if (!(instance instanceof OriginalAuraInfo)) + throw new UnsupportedOperationException("Can't serialize non-API implementation"); + + return ((OriginalAuraInfo) instance).serializeNBT(); + } + }, OriginalAuraInfo::new); + ResearchApi.registerScanParser(new ScanParserBlock(), 1000); + ResearchApi.registerScanParser(new ScanParserItem(), 1000); + ResearchApi.registerScanParser(new ScanParserItemExtended(), 1000); + ResearchApi.registerScanParser(new ScanParserEntity(), 1000); + ResearchApi.registerResearchEntrySource(Paths.get("config", ThaumcraftFixApi.MODID, "entries")); + ResearchApi.registerResearchPatchSource(Paths.get("config", ThaumcraftFixApi.MODID, "patches"), 1000); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/alchemy.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/artifice.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/auromancy.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/basics.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/eldritch.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/golemancy.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/infusion.json"), -1); + ResearchApi.registerResearchPatchSource(new ResourceLocation(ThaumcraftFixApi.MODID, "research/patches/scans.json"), -1); } @SubscribeEvent(priority = EventPriority.LOW) public static void afterThaumcraftRegistersItems(RegistryEvent event) { - // we want to run a bunch of static initializers at a consistent time - try { - Class.forName("thaumcraft.common.golems.GolemProperties"); - } - catch (ClassNotFoundException ex) { - // if we don't have GolemProperties golems will be broken... - throw new RuntimeException(ex); - } + // we want to run a bunch of static initializers at a consistent time + try { + Class.forName("thaumcraft.common.golems.GolemProperties"); + } catch (ClassNotFoundException ex) { + // if we don't have GolemProperties golems will be broken... + throw new RuntimeException(ex); + } } @EventHandler public void init(FMLInitializationEvent event) { - network = new ThaumcraftFixNetworkHandler(); - GameRegistry.registerWorldGenerator(new AuraFinalizerWorldGenerator(), Integer.MAX_VALUE); - boolean errors = ResearchConfigParser.loadCategories(); - errors |= ResearchConfigParser.loadScans(); - errors |= ResearchConfigParser.loadAdvancements(); - if (errors) { - logger.error("One or more research errors have occurred. Please check the log file for more information."); - } + network = new ThaumcraftFixNetworkHandler(); + GameRegistry.registerWorldGenerator(new AuraFinalizerWorldGenerator(), Integer.MAX_VALUE); + boolean errors = ResearchConfigParser.loadCategories(); + errors |= ResearchConfigParser.loadScans(); + errors |= ResearchConfigParser.loadAdvancements(); + if (errors) { + logger.error("One or more research errors have occurred. Please check the log file for more information."); + } } private static void setToolMaterialRepairItem(ToolMaterial material, ItemStack repair) { - try { - material.setRepairItem(repair); - } - catch (RuntimeException ex) { - // someone already set repair items - } + try { + material.setRepairItem(repair); + } catch (RuntimeException ex) { + // someone already set repair items + } } private static void setArmorMaterialRepairItem(ArmorMaterial material, ItemStack repair) { - try { - material.setRepairItem(repair); - } - catch (RuntimeException ex) { - // someone already set repair items - } + try { + material.setRepairItem(repair); + } catch (RuntimeException ex) { + // someone already set repair items + } } //Wrapper function for registering aspects to an entity. @SuppressWarnings("deprecation") private static void registerEntityAspects(String entityName, AspectList aspectList) { - ThaumcraftApi.registerEntityTag(entityName, aspectList); + ThaumcraftApi.registerEntityTag(entityName, aspectList); } @EventHandler public void postInit(FMLPostInitializationEvent event) { - ThaumcraftFixApiBridge.implementation().reloadConfig(); - - // reset repair materials for TC materials - // if the class was loaded before now, the items used will have been null and won't register - // the individual items have extra code to allow repair, but these are required for generic support - setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_ELEMENTAL, new ItemStack(ItemsTC.ingots, 1, 0)); - setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_THAUMIUM, new ItemStack(ItemsTC.ingots, 1, 0)); - setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_VOID, new ItemStack(ItemsTC.ingots, 1, 1)); - - // these just don't have repair materials defined - // should these be replaced with plates? would also need to override every class usage... - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_LEADER, new ItemStack(Items.IRON_INGOT)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_PLATE, new ItemStack(Items.IRON_INGOT)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_ROBE, new ItemStack(Items.IRON_INGOT)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_FORTRESS, new ItemStack(ItemsTC.ingots, 1, 0)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_THAUMIUM, new ItemStack(ItemsTC.ingots, 1, 0)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_VOID, new ItemStack(ItemsTC.ingots, 1, 1)); - setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_VOIDROBE, new ItemStack(ItemsTC.ingots, 1, 1)); - - // these don't have repair materials and are shared across multiple items - // it doesn't really make sense to have a single repair material for it - // ThaumcraftMaterials.ARMORMAT_SPECIAL - - - //Register additional entity aspects, start off with turrets... - registerEntityAspects("ArcaneBore", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.TOOL, 10).add(Aspect.MAGIC, 10).add(Aspect.ENTROPY, 10)); - registerEntityAspects("TurretBasic", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.AVERSION, 10).add(Aspect.MAGIC, 10)); - registerEntityAspects("TurretAdvanced", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.AVERSION, 10).add(Aspect.MAGIC, 10).add(Aspect.MIND, 10)); - - //Taint stuff... - registerEntityAspects("TaintCrawler", new AspectList().add(Aspect.FLUX, 5).add(Aspect.BEAST, 5)); - - //Cult stuff... - registerEntityAspects("CultistPortalLesser", new AspectList().add(Aspect.AURA, 20).add(Aspect.ELDRITCH, 20).add(Aspect.AVERSION, 20)); - registerEntityAspects("CultistPortalGreater", new AspectList().add(Aspect.AURA, 40).add(Aspect.ELDRITCH, 40).add(Aspect.AVERSION, 40)); - - //Machine projectiles... - registerEntityAspects("Grapple", new AspectList().add(Aspect.MECHANISM, 5).add(Aspect.MAGIC, 5).add(Aspect.TRAP, 5)); - registerEntityAspects("GolemDart", new AspectList().add(Aspect.AVERSION, 5).add(Aspect.MOTION, 5)); - - //Misc projectiles... - registerEntityAspects("Alumentum", new AspectList().add(Aspect.ENERGY, 10).add(Aspect.FIRE, 10).add(Aspect.ENTROPY, 5).add(Aspect.MOTION, 5)); - registerEntityAspects("CausalityCollapser", new AspectList().add(Aspect.ENERGY, 40).add(Aspect.FIRE, 40).add(Aspect.ENTROPY, 20).add(Aspect.MOTION, 5).add(Aspect.ELDRITCH, 10)); - registerEntityAspects("BottleTaint", new AspectList().add(Aspect.FLUX, 15).add(Aspect.WATER, 5).add(Aspect.MOTION, 5)); - registerEntityAspects("FallingTaint", new AspectList().add(Aspect.MOTION, 5).add(Aspect.FLUX, 5)); - registerEntityAspects("EldritchOrb", new AspectList().add(Aspect.ELDRITCH, 5).add(Aspect.MOTION, 5).add(Aspect.AVERSION, 5)); - registerEntityAspects("GolemOrb", new AspectList().add(Aspect.ENERGY, 5).add(Aspect.MOTION, 5).add(Aspect.AVERSION, 5)); - - //And finally casted entities. - registerEntityAspects("FocusCloud", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.ALCHEMY, 10)); - registerEntityAspects("Focusmine", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.TRAP, 10)); - registerEntityAspects("FocusProjectile", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.MOTION, 10)); - - //Can be cheesed easily, so comment spellbat aspects out for now. - //registerEntityAspects("Spellbat", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.BEAST, 10)); - - - // delete broken spellbat spawn egg - EntityEntry spellbat = EntityRegistry.getEntry(EntitySpellBat.class); - if (spellbat != null) { - spellbat.setEgg(null); - EntityList.ENTITY_EGGS.remove(spellbat.getRegistryName()); - } + ThaumcraftFixApiBridge.implementation().reloadConfig(); + + // reset repair materials for TC materials + // if the class was loaded before now, the items used will have been null and won't register + // the individual items have extra code to allow repair, but these are required for generic support + setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_ELEMENTAL, new ItemStack(ItemsTC.ingots, 1, 0)); + setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_THAUMIUM, new ItemStack(ItemsTC.ingots, 1, 0)); + setToolMaterialRepairItem(ThaumcraftMaterials.TOOLMAT_VOID, new ItemStack(ItemsTC.ingots, 1, 1)); + + // these just don't have repair materials defined + // should these be replaced with plates? would also need to override every class usage... + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_LEADER, new ItemStack(Items.IRON_INGOT)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_PLATE, new ItemStack(Items.IRON_INGOT)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_CULTIST_ROBE, new ItemStack(Items.IRON_INGOT)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_FORTRESS, new ItemStack(ItemsTC.ingots, 1, 0)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_THAUMIUM, new ItemStack(ItemsTC.ingots, 1, 0)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_VOID, new ItemStack(ItemsTC.ingots, 1, 1)); + setArmorMaterialRepairItem(ThaumcraftMaterials.ARMORMAT_VOIDROBE, new ItemStack(ItemsTC.ingots, 1, 1)); + + // these don't have repair materials and are shared across multiple items + // it doesn't really make sense to have a single repair material for it + // ThaumcraftMaterials.ARMORMAT_SPECIAL + + + //Register additional entity aspects, start off with turrets... + registerEntityAspects("ArcaneBore", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.TOOL, 10).add(Aspect.MAGIC, 10).add(Aspect.ENTROPY, 10)); + registerEntityAspects("TurretBasic", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.AVERSION, 10).add(Aspect.MAGIC, 10)); + registerEntityAspects("TurretAdvanced", new AspectList().add(Aspect.MECHANISM, 10).add(Aspect.AVERSION, 10).add(Aspect.MAGIC, 10).add(Aspect.MIND, 10)); + + //Taint stuff... + registerEntityAspects("TaintCrawler", new AspectList().add(Aspect.FLUX, 5).add(Aspect.BEAST, 5)); + + //Cult stuff... + registerEntityAspects("CultistPortalLesser", new AspectList().add(Aspect.AURA, 20).add(Aspect.ELDRITCH, 20).add(Aspect.AVERSION, 20)); + registerEntityAspects("CultistPortalGreater", new AspectList().add(Aspect.AURA, 40).add(Aspect.ELDRITCH, 40).add(Aspect.AVERSION, 40)); + + //Machine projectiles... + registerEntityAspects("Grapple", new AspectList().add(Aspect.MECHANISM, 5).add(Aspect.MAGIC, 5).add(Aspect.TRAP, 5)); + registerEntityAspects("GolemDart", new AspectList().add(Aspect.AVERSION, 5).add(Aspect.MOTION, 5)); + + //Misc projectiles... + registerEntityAspects("Alumentum", new AspectList().add(Aspect.ENERGY, 10).add(Aspect.FIRE, 10).add(Aspect.ENTROPY, 5).add(Aspect.MOTION, 5)); + registerEntityAspects("CausalityCollapser", new AspectList().add(Aspect.ENERGY, 40).add(Aspect.FIRE, 40).add(Aspect.ENTROPY, 20).add(Aspect.MOTION, 5).add(Aspect.ELDRITCH, 10)); + registerEntityAspects("BottleTaint", new AspectList().add(Aspect.FLUX, 15).add(Aspect.WATER, 5).add(Aspect.MOTION, 5)); + registerEntityAspects("FallingTaint", new AspectList().add(Aspect.MOTION, 5).add(Aspect.FLUX, 5)); + registerEntityAspects("EldritchOrb", new AspectList().add(Aspect.ELDRITCH, 5).add(Aspect.MOTION, 5).add(Aspect.AVERSION, 5)); + registerEntityAspects("GolemOrb", new AspectList().add(Aspect.ENERGY, 5).add(Aspect.MOTION, 5).add(Aspect.AVERSION, 5)); + + //And finally casted entities. + registerEntityAspects("FocusCloud", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.ALCHEMY, 10)); + registerEntityAspects("Focusmine", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.TRAP, 10)); + registerEntityAspects("FocusProjectile", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.MOTION, 10)); + + //Can be cheesed easily, so comment spellbat aspects out for now. + //registerEntityAspects("Spellbat", new AspectList().add(Aspect.AURA, 10).add(Aspect.MAGIC, 10).add(Aspect.BEAST, 10)); + + + // delete broken spellbat spawn egg + EntityEntry spellbat = EntityRegistry.getEntry(EntitySpellBat.class); + if (spellbat != null) { + spellbat.setEgg(null); + EntityList.ENTITY_EGGS.remove(spellbat.getRegistryName()); + } + + ResearchConfigParser.researchPostInit(); } @EventHandler public void loadComplete(FMLLoadCompleteEvent event) { - ThaumcraftFixApiBridge.InternalImplementation impl = ThaumcraftFixApiBridge.implementation(); - if (impl instanceof DefaultApiImplementation) { - ImmutableSet.Builder allowed = ImmutableSet.builder(); - for (ResearchCategory category : ResearchCategories.researchCategories.values()) { - for (ResearchEntry entry : category.research.values()) { - if (entry.getStages() != null) { - for (ResearchStage stage : entry.getStages()) { - if (stage.getKnow() != null) { - for (Knowledge know : stage.getKnow()) { - if (know.type == EnumKnowledgeType.THEORY && know.category != null) { - allowed.add(know.category); - } - } - } - } - } - } - } - - ((DefaultApiImplementation) impl).setAllowedTheorycraftCategories(allowed.build()); - logger.debug("The following research categories will be allowed for theorycrafting:"); - for (ResearchCategory c : ResearchCategoryTheorycraftFilter.getAllowedTheorycraftCategories()) { - logger.debug("{}", c.key); - } - } + ThaumcraftFixApiBridge.InternalImplementation impl = ThaumcraftFixApiBridge.implementation(); + if (impl instanceof DefaultApiImplementation) { + ImmutableSet.Builder allowed = ImmutableSet.builder(); + for (ResearchCategory category : ResearchCategories.researchCategories.values()) { + for (ResearchEntry entry : category.research.values()) { + if (entry.getStages() != null) { + for (ResearchStage stage : entry.getStages()) { + if (stage.getKnow() != null) { + for (Knowledge know : stage.getKnow()) { + if (know.type == EnumKnowledgeType.THEORY && know.category != null) { + allowed.add(know.category); + } + } + } + } + } + } + } + + ((DefaultApiImplementation) impl).setAllowedTheorycraftCategories(allowed.build()); + logger.debug("The following research categories will be allowed for theorycrafting:"); + for (ResearchCategory c : ResearchCategoryTheorycraftFilter.getAllowedTheorycraftCategories()) { + logger.debug("{}", c.key); + } + } } @EventHandler public static void onFingerPrintViolation(FMLFingerprintViolationEvent event) { - if (!event.isDirectory()) { - Logger tempLogger = LogManager.getLogger(ThaumcraftFixApi.MODID); - tempLogger.warn("A file failed to match with the signing key."); - tempLogger.warn("If you *know* this is a homebrew/custom build then this is expected, carry on."); - tempLogger.warn("Otherwise, you might want to redownload this mod from the *official* CurseForge page."); - } + if (!event.isDirectory()) { + Logger tempLogger = LogManager.getLogger(ThaumcraftFixApi.MODID); + tempLogger.warn("A file failed to match with the signing key."); + tempLogger.warn("If you *know* this is a homebrew/custom build then this is expected, carry on."); + tempLogger.warn("Otherwise, you might want to redownload this mod from the *official* CurseForge page."); + } } public Logger getLogger() { - return logger; + return logger; } public SimpleNetworkWrapper getNetworkHandler() { - return network; + return network; } } diff --git a/src/main/java/thecodex6824/thaumcraftfix/common/ThaumcraftFixConfig.java b/src/main/java/thecodex6824/thaumcraftfix/common/ThaumcraftFixConfig.java index 25d0794..f73bb6a 100644 --- a/src/main/java/thecodex6824/thaumcraftfix/common/ThaumcraftFixConfig.java +++ b/src/main/java/thecodex6824/thaumcraftfix/common/ThaumcraftFixConfig.java @@ -162,6 +162,14 @@ public static class VegetationConfig { } + @Name("CategoriesToRemove") + @Comment({ + "The keys of categories that should be deleted.", + "Note that categories are not automatically deleted (even when having no entries) due to addon incompatibilities." + }) + @Config.RequiresMcRestart + public static String[] removedCategories = {}; + @Name("world") @LangKey(ThaumcraftFixApi.MODID + ".text.config.world") public static WorldConfig world = new WorldConfig(); diff --git a/src/main/java/thecodex6824/thaumcraftfix/common/research/ResearchConfigParser.java b/src/main/java/thecodex6824/thaumcraftfix/common/research/ResearchConfigParser.java index 9d2edf5..c2acc3e 100644 --- a/src/main/java/thecodex6824/thaumcraftfix/common/research/ResearchConfigParser.java +++ b/src/main/java/thecodex6824/thaumcraftfix/common/research/ResearchConfigParser.java @@ -43,6 +43,7 @@ import thaumcraft.api.research.ScanningManager; import thecodex6824.thaumcraftfix.ThaumcraftFix; import thecodex6824.thaumcraftfix.api.ResearchApi; +import thecodex6824.thaumcraftfix.common.ThaumcraftFixConfig; import thecodex6824.thaumcraftfix.common.event.AdvancementResearchEventHandler; import thecodex6824.thaumcraftfix.common.json.JsonSchemaException; import thecodex6824.thaumcraftfix.common.json.JsonUtils; @@ -189,4 +190,18 @@ public boolean accept(File f) { return researchErrors; } + public static void researchPostInit() { + Logger log = ThaumcraftFix.instance.getLogger(); + for (String s : ThaumcraftFixConfig.removedCategories) { + if (ResearchCategories.researchCategories.remove(s) != null) + log.info("Removing research category " + s); + else + log.warn("Research category " + s + " was supposed to be removed, but did not exist"); + } + + // "reminder" because init / model loading often causes log spam + //if (researchErrors) + // log.error("One or more research errors have occurred. Please check the log file for more information."); + } + }