From e21fe3eeccf8c8fc92919ae16ed53a9f8e387c0f Mon Sep 17 00:00:00 2001 From: Boblet Date: Wed, 5 Mar 2025 16:57:50 +0100 Subject: [PATCH] config crap --- README.md | 1 + changelog | 5 +- .../java/com/hbm/config/ClientConfig.java | 13 ++--- .../java/com/hbm/config/GeneralConfig.java | 6 --- .../java/com/hbm/config/RunningConfig.java | 6 +++ .../java/com/hbm/config/ServerConfig.java | 12 ++--- .../hbm/entity/mob/EntityCreeperTainted.java | 6 +-- .../recipes/loader/SerializableRecipe.java | 4 +- .../hbm/items/weapon/sedna/ItemGunBaseNT.java | 3 ++ .../java/com/hbm/main/CraftingManager.java | 48 ++++++++++-------- src/main/java/com/hbm/potion/HbmPotion.java | 4 +- .../hbm/textures/items/syringe_taint.png | Bin 294 -> 354 bytes 12 files changed, 56 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 68e85a68ee..f868032006 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ * NTM Reloaded: https://github.com/TheOriginalGolem/Hbm-s-Nuclear-Tech-GIT/releases * NTM Extended Edition (Alcater): https://github.com/Alcatergit/Hbm-s-Nuclear-Tech-GIT/releases +* NTM WarFactory: https://github.com/MisterNorwood/Hbm-s-Nuclear-Tech-GIT/releases For 1.18, try Martin's remake: https://codeberg.org/MartinTheDragon/Nuclear-Tech-Mod-Remake/releases diff --git a/changelog b/changelog index 3122e1cbf9..087101ec03 100644 --- a/changelog +++ b/changelog @@ -3,6 +3,7 @@ * Functions like `/ntmclient` but for common settings * Can toggle `DAMAGE_COMPATIBILITY_MODE`, off by default, enables a more compatible (but slightly jankier) version of the bullet damage code * `MINE__DAMAGE` can be used to adjust landmine damage + * `TAINT_TRAILS` now replaces the hardcore taint config option, making taint blocks more potent and the potion effect trail taint blocks ## Changed * Fat mines now use the standardized mini nuke code @@ -17,8 +18,10 @@ * Taint has a 25% chance of splashing down when replacing a block with no supports, causing structures to collapse and taint to spread faster * Similar to soil sand, entities will sink in taint and get slowed down * The sludge consumeth +* `enableGuns` config option now applies to SEDNA system guns, simply canceling all gun-related keybinds ## Fixed * Fixed animation error on the MAS-36 * Fixed drone docks, requester and provider crates not dropping their contents when broken -* Fixed all missing texture errors that appear in the startup log \ No newline at end of file +* Fixed all missing texture errors that appear in the startup log +* Potentially fixed a crash with mekanism during the recipe change phase \ No newline at end of file diff --git a/src/main/java/com/hbm/config/ClientConfig.java b/src/main/java/com/hbm/config/ClientConfig.java index 2f5cec9023..e5905a1356 100644 --- a/src/main/java/com/hbm/config/ClientConfig.java +++ b/src/main/java/com/hbm/config/ClientConfig.java @@ -1,15 +1,13 @@ package com.hbm.config; import com.google.gson.Gson; -import com.hbm.config.RunningConfig.ConfigWrapper; -import com.hbm.main.MainRegistry; import com.hbm.util.Compat; import java.io.File; import java.util.HashMap; // https://youtube.com/shorts/XTHZWqZt_AI -public class ClientConfig { +public class ClientConfig extends RunningConfig { public static final Gson gson = new Gson(); public static HashMap configMap = new HashMap(); @@ -56,23 +54,20 @@ private static void initDefaults() { /** Initializes defaults, then reads the config file if it exists, then writes the config file. */ public static void initConfig() { initDefaults(); - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json"); + File config = getConfig("hbmClient.json"); if(config.exists()) readConfig(config); refresh(); } /** Writes over the config file using the running config. */ public static void refresh() { - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json"); + File config = getConfig("hbmClient.json"); writeConfig(config); } /** Writes over the running config using the config file. */ public static void reload() { - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmClient.json"); + File config = getConfig("hbmClient.json"); if(config.exists()) readConfig(config); } diff --git a/src/main/java/com/hbm/config/GeneralConfig.java b/src/main/java/com/hbm/config/GeneralConfig.java index 916bd9e9c0..0393849404 100644 --- a/src/main/java/com/hbm/config/GeneralConfig.java +++ b/src/main/java/com/hbm/config/GeneralConfig.java @@ -23,13 +23,11 @@ public class GeneralConfig { public static boolean enableVaults = true; public static boolean enableCataclysm = false; public static boolean enableExtendedLogging = false; - public static boolean enableHardcoreTaint = false; public static boolean enableGuns = true; public static boolean enableVirus = true; public static boolean enableCrosshairs = true; public static boolean enableReflectorCompat = false; public static boolean enableRenderDistCheck = true; - public static boolean enableReEval = true; public static boolean enableSilentCompStackErrors = true; public static boolean enableSkyboxes = true; public static boolean enableImpactWorldProvider = true; @@ -42,7 +40,6 @@ public class GeneralConfig { public static boolean enableSoundExtension = true; public static boolean enableMekanismChanges = true; public static int normalSoundChannels = 200; - public static int hintPos = 0; public static boolean enableExpensiveMode = false; @@ -100,15 +97,12 @@ public static void loadFromConfig(Configuration config) { enableVaults = config.get(CATEGORY_GENERAL, "1.15_enableVaultSpawn", true, "Allows locked safes to spawn").getBoolean(true); enableCataclysm = config.get(CATEGORY_GENERAL, "1.17_enableCataclysm", false, "Causes satellites to fall whenever a mob dies").getBoolean(false); enableExtendedLogging = config.get(CATEGORY_GENERAL, "1.18_enableExtendedLogging", false, "Logs uses of the detonator, nuclear explosions, missile launches, grenades, etc.").getBoolean(false); - enableHardcoreTaint = config.get(CATEGORY_GENERAL, "1.19_enableHardcoreTaint", false, "Allows tainted mobs to spread taint").getBoolean(false); enableGuns = config.get(CATEGORY_GENERAL, "1.20_enableGuns", true, "Prevents new system guns to be fired").getBoolean(true); enableVirus = config.get(CATEGORY_GENERAL, "1.21_enableVirus", false, "Allows virus blocks to spread").getBoolean(false); enableCrosshairs = config.get(CATEGORY_GENERAL, "1.22_enableCrosshairs", true, "Shows custom crosshairs when an NTM gun is being held").getBoolean(true); enableReflectorCompat = config.get(CATEGORY_GENERAL, "1.24_enableReflectorCompat", false, "Enable old reflector oredict name (\"plateDenseLead\") instead of new \"plateTungCar\"").getBoolean(false); enableRenderDistCheck = config.get(CATEGORY_GENERAL, "1.25_enableRenderDistCheck", true, "Check invalid render distances (over 16, without OptiFine) and fix it").getBoolean(true); - enableReEval = config.get(CATEGORY_GENERAL, "1.27_enableReEval", true, "Allows re-evaluating power networks on link remove instead of destroying and recreating").getBoolean(true); enableSilentCompStackErrors = config.get(CATEGORY_GENERAL, "1.28_enableSilentCompStackErrors", false, "Enabling this will disable log spam created by unregistered items in ComparableStack instances.").getBoolean(false); - hintPos = CommonConfig.createConfigInt(config, CATEGORY_GENERAL, "1.29_hudOverlayPosition", "0: Top left\n1: Top right\n2: Center right\n3: Center Left", 0); enableSkyboxes = config.get(CATEGORY_GENERAL, "1.31_enableSkyboxes", true, "If enabled, will try to use NTM's custom skyboxes.").getBoolean(true); enableImpactWorldProvider = config.get(CATEGORY_GENERAL, "1.32_enableImpactWorldProvider", true, "If enabled, registers custom world provider which modifies lighting and sky colors for post impact effects.").getBoolean(true); enableStatReRegistering = config.get(CATEGORY_GENERAL, "1.33_enableStatReRegistering", true, "If enabled, will re-register item crafting/breaking/usage stats in order to fix a forge bug where modded items just won't show up.").getBoolean(true); diff --git a/src/main/java/com/hbm/config/RunningConfig.java b/src/main/java/com/hbm/config/RunningConfig.java index 66ebe91936..453a123b21 100644 --- a/src/main/java/com/hbm/config/RunningConfig.java +++ b/src/main/java/com/hbm/config/RunningConfig.java @@ -14,10 +14,16 @@ import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.stream.JsonWriter; +import com.hbm.main.MainRegistry; public class RunningConfig { public static final Gson gson = new Gson(); + + public static File getConfig(String name) { + File folder = MainRegistry.configHbmDir; + return new File(folder.getAbsolutePath() + File.separatorChar + name); + } public static void readConfig(File config, HashMap configMap) { diff --git a/src/main/java/com/hbm/config/ServerConfig.java b/src/main/java/com/hbm/config/ServerConfig.java index fd95861130..0ae3d11a2c 100644 --- a/src/main/java/com/hbm/config/ServerConfig.java +++ b/src/main/java/com/hbm/config/ServerConfig.java @@ -4,7 +4,6 @@ import java.util.HashMap; import com.google.gson.Gson; -import com.hbm.main.MainRegistry; public class ServerConfig extends RunningConfig { @@ -16,6 +15,7 @@ public class ServerConfig extends RunningConfig { public static ConfigWrapper MINE_HE_DAMAGE = new ConfigWrapper(35F); public static ConfigWrapper MINE_SHRAP_DAMAGE = new ConfigWrapper(7.5F); public static ConfigWrapper MINE_NUKE_DAMAGE = new ConfigWrapper(100F); + public static ConfigWrapper TAINT_TRAILS = new ConfigWrapper(false); private static void initDefaults() { configMap.put("DAMAGE_COMPATIBILITY_MODE", DAMAGE_COMPATIBILITY_MODE); @@ -23,28 +23,26 @@ private static void initDefaults() { configMap.put("MINE_HE_DAMAGE", MINE_HE_DAMAGE); configMap.put("MINE_SHRAP_DAMAGE", MINE_SHRAP_DAMAGE); configMap.put("MINE_NUKE_DAMAGE", MINE_NUKE_DAMAGE); + configMap.put("TAINT_TRAILS", TAINT_TRAILS); } /** Initializes defaults, then reads the config file if it exists, then writes the config file. */ public static void initConfig() { initDefaults(); - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmServer.json"); + File config = getConfig("hbmServer.json"); if(config.exists()) readConfig(config); refresh(); } /** Writes over the config file using the running config. */ public static void refresh() { - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmServer.json"); + File config = getConfig("hbmServer.json"); writeConfig(config); } /** Writes over the running config using the config file. */ public static void reload() { - File folder = MainRegistry.configHbmDir; - File config = new File(folder.getAbsolutePath() + File.separatorChar + "hbmServer.json"); + File config = getConfig("hbmServer.json"); if(config.exists()) readConfig(config); } diff --git a/src/main/java/com/hbm/entity/mob/EntityCreeperTainted.java b/src/main/java/com/hbm/entity/mob/EntityCreeperTainted.java index 1997caa330..cbb20b671e 100644 --- a/src/main/java/com/hbm/entity/mob/EntityCreeperTainted.java +++ b/src/main/java/com/hbm/entity/mob/EntityCreeperTainted.java @@ -1,7 +1,7 @@ package com.hbm.entity.mob; import com.hbm.blocks.ModBlocks; -import com.hbm.config.GeneralConfig; +import com.hbm.config.ServerConfig; import api.hbm.entity.IRadiationImmune; import net.minecraft.block.Block; @@ -57,7 +57,7 @@ public void func_146077_cc() { int c = rand.nextInt(15) + (int) posZ - 7; Block block = worldObj.getBlock(a, b, c); if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) { - if(!GeneralConfig.enableHardcoreTaint) { + if(!ServerConfig.TAINT_TRAILS.get()) { worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 5, 2); } else { worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3), 2); @@ -73,7 +73,7 @@ public void func_146077_cc() { int c = rand.nextInt(7) + (int) posZ - 3; Block block = worldObj.getBlock(a, b, c); if(block.isNormalCube() && !block.isAir(worldObj, a, b, c)) { - if(!GeneralConfig.enableHardcoreTaint) { + if(!ServerConfig.TAINT_TRAILS.get()) { worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(6) + 10, 2); } else { worldObj.setBlock(a, b, c, ModBlocks.taint, rand.nextInt(3) + 4, 2); diff --git a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java index 7b99b1b9fb..02db7b3890 100644 --- a/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java +++ b/src/main/java/com/hbm/inventory/recipes/loader/SerializableRecipe.java @@ -33,7 +33,7 @@ import net.minecraft.item.ItemStack; //the anti-spaghetti. this class provides so much functionality and saves so much time, i just love you, SerializableRecipe <3 -public abstract class SerializableRecipe { +public abstract class SerializableRecipe { //TODO: #1969 public static final Gson gson = new Gson(); public static List recipeHandlers = new ArrayList(); @@ -141,7 +141,7 @@ public static void initialize() { public abstract void writeRecipe(Object recipe, JsonWriter writer) throws IOException; /** Registers the default recipes */ public abstract void registerDefaults(); - /** Deletes all existing recipes, currenly unused */ + /** Deletes all existing recipes, currently unused */ public abstract void deleteRecipes(); /** A routine called after registering all recipes, whether it's a template or not. Good for IMC functionality. */ public void registerPost() { } diff --git a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java index ce88b06dfd..96a9b099f5 100644 --- a/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java +++ b/src/main/java/com/hbm/items/weapon/sedna/ItemGunBaseNT.java @@ -5,6 +5,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; +import com.hbm.config.GeneralConfig; import com.hbm.handler.HbmKeybinds.EnumKeybind; import com.hbm.interfaces.IItemHUD; import com.hbm.items.IEquipReceiver; @@ -169,6 +170,8 @@ public void handleKeybind(EntityPlayer player, ItemStack stack, EnumKeybind keyb } public void handleKeybind(EntityLivingBase entity, IInventory inventory, ItemStack stack, EnumKeybind keybind, boolean newState) { + if(!GeneralConfig.enableGuns) return; + int configs = this.configs_DNA.length; for(int i = 0; i < configs; i++) { diff --git a/src/main/java/com/hbm/main/CraftingManager.java b/src/main/java/com/hbm/main/CraftingManager.java index dd130b852b..240886151c 100644 --- a/src/main/java/com/hbm/main/CraftingManager.java +++ b/src/main/java/com/hbm/main/CraftingManager.java @@ -1175,30 +1175,34 @@ public static void crumple() { List toDestroy = new ArrayList(); - for(Object o : net.minecraft.item.crafting.CraftingManager.getInstance().getRecipeList()) { - - if(o instanceof IRecipe) { - IRecipe rec = (IRecipe)o; - ItemStack stack = rec.getRecipeOutput(); - - for(ItemStack target : targets) { - if(stack != null && stack.getItem() == target.getItem() && stack.getItemDamage() == target.getItemDamage()) toDestroy.add(rec); + List recipeList = net.minecraft.item.crafting.CraftingManager.getInstance().getRecipeList(); + + synchronized(recipeList) { //this is how threading works. i think. + for(Object o : recipeList) { + + if(o instanceof IRecipe) { + IRecipe rec = (IRecipe)o; + ItemStack stack = rec.getRecipeOutput(); + + for(ItemStack target : targets) { + if(stack != null && stack.getItem() == target.getItem() && stack.getItemDamage() == target.getItemDamage()) toDestroy.add(rec); + } } } - } - - if(toDestroy.size() > 0) { - net.minecraft.item.crafting.CraftingManager.getInstance().getRecipeList().removeAll(toDestroy); - } - - if(Loader.isModLoaded("Mekanism")) { - Item disassembler = (Item) Item.itemRegistry.getObject("Mekanism:AtomicDisassembler"); - if(disassembler != null) addRecipeAuto(new ItemStack(disassembler, 1), "GAG", "EIE", " I ", 'G', GOLD.plateCast(), 'A', "alloyUltimate", 'E', "battery", 'I', "ingotRefinedObsidian"); - } - - if(Loader.isModLoaded("MekanismGenerators")) { - Block generator = (Block) Block.blockRegistry.getObject("MekanismGenerators:Generator"); - if(generator != null) addRecipeAuto(new ItemStack(generator, 1, 6), " T ", "TAT", "BCB", 'T', TI.plateCast(), 'A', "alloyAdvanced", 'B', "battery", 'C', ANY_PLASTIC.ingot()); + + if(toDestroy.size() > 0) { + recipeList.removeAll(toDestroy); + } + + if(Loader.isModLoaded("Mekanism")) { + Item disassembler = (Item) Item.itemRegistry.getObject("Mekanism:AtomicDisassembler"); + if(disassembler != null) addRecipeAuto(new ItemStack(disassembler, 1), "GAG", "EIE", " I ", 'G', GOLD.plateCast(), 'A', "alloyUltimate", 'E', "battery", 'I', "ingotRefinedObsidian"); + } + + if(Loader.isModLoaded("MekanismGenerators")) { + Block generator = (Block) Block.blockRegistry.getObject("MekanismGenerators:Generator"); + if(generator != null) addRecipeAuto(new ItemStack(generator, 1, 6), " T ", "TAT", "BCB", 'T', TI.plateCast(), 'A', "alloyAdvanced", 'B', "battery", 'C', ANY_PLASTIC.ingot()); + } } } } diff --git a/src/main/java/com/hbm/potion/HbmPotion.java b/src/main/java/com/hbm/potion/HbmPotion.java index e27806e1a1..c1189b8b65 100644 --- a/src/main/java/com/hbm/potion/HbmPotion.java +++ b/src/main/java/com/hbm/potion/HbmPotion.java @@ -3,8 +3,8 @@ import java.lang.reflect.Field; import com.hbm.blocks.ModBlocks; -import com.hbm.config.GeneralConfig; import com.hbm.config.PotionConfig; +import com.hbm.config.ServerConfig; import com.hbm.entity.mob.EntityTaintCrab; import com.hbm.entity.mob.EntityCreeperTainted; import com.hbm.explosion.ExplosionLarge; @@ -107,7 +107,7 @@ public void performEffect(EntityLivingBase entity, int level) { if(!(entity instanceof EntityCreeperTainted) && !(entity instanceof EntityTaintCrab) && entity.worldObj.rand.nextInt(40) == 0) entity.attackEntityFrom(ModDamageSource.taint, (level + 1)); - if(GeneralConfig.enableHardcoreTaint && !entity.worldObj.isRemote) { + if(ServerConfig.TAINT_TRAILS.get() && !entity.worldObj.isRemote) { int x = (int) Math.floor(entity.posX); int y = (int) Math.floor(entity.posY); diff --git a/src/main/resources/assets/hbm/textures/items/syringe_taint.png b/src/main/resources/assets/hbm/textures/items/syringe_taint.png index 51f837e60fc5d17928427d8c5ea96232e302b7df..bfa6a581a3605c0337e5b27be433f59fb7a48227 100644 GIT binary patch delta 312 zcmV-80muHP0^$OYGk*aYNkl1u24ObLr#q}*c?7_4ICQ(0N~wc~K@f-{ zK{Y!(KfNG;*F>{u%-9~Sh~pSZO3i`R+U<(8)-DJFkqbViZ-0EJ23!Ba&Zjt;GPoX~ z+8wqF!EOHmuj=KZg9&ExojC^K41Q&abSaPbH*9K6n(~-Vy~}C)3}XyRDU31uf|K(u zlgXT>@MtWTuv&wJ&vgZ}GW74RP)g-1WVscFSQKbkhNikk~y&l$DthJ0rBT*>G2*c3%zE2#-WHtNr&-ejYx^>Aq!b~mz0000< KMNUMnLSTX)_LXh` delta 251 zcmV*@h;)qG(UGDESSJ#j4PYu4 z(NqJ0ECZC1BQb4SXw$jj2;AFbiG6T{xe`Bc4d#XBu=tfQ#K;!AIBhe;ag3&E{7lmn zL