Merge pull request #1767 from FOlkvangrField/Custom-fluid-pollution-fix

Custom fluid traits fix
This commit is contained in:
HbmMods 2024-12-16 16:08:51 +01:00 committed by GitHub
commit 78d61348bf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 133 additions and 100 deletions

View File

@ -1,7 +1,9 @@
package com.hbm.commands; package com.hbm.commands;
import com.hbm.config.ItemPoolConfigJSON; import com.hbm.config.ItemPoolConfigJSON;
import com.hbm.inventory.fluid.Fluids;
import com.hbm.inventory.recipes.loader.SerializableRecipe; import com.hbm.inventory.recipes.loader.SerializableRecipe;
import com.hbm.main.MainRegistry;
import com.hbm.util.ChatBuilder; import com.hbm.util.ChatBuilder;
import com.hbm.util.DamageResistanceHandler; import com.hbm.util.DamageResistanceHandler;
@ -10,6 +12,10 @@ import net.minecraft.command.ICommandSender;
import net.minecraft.util.ChatComponentText; import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting; import net.minecraft.util.EnumChatFormatting;
import java.io.File;
public class CommandReloadRecipes extends CommandBase { public class CommandReloadRecipes extends CommandBase {
@Override @Override
@ -28,6 +34,8 @@ public class CommandReloadRecipes extends CommandBase {
SerializableRecipe.initialize(); SerializableRecipe.initialize();
ItemPoolConfigJSON.initialize(); ItemPoolConfigJSON.initialize();
DamageResistanceHandler.init(); DamageResistanceHandler.init();
Fluids.reloadFluids();
sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)")); sender.addChatMessage(new ChatComponentText(EnumChatFormatting.YELLOW + "Reload complete :)"));
} catch(Exception ex) { } catch(Exception ex) {
sender.addChatMessage(ChatBuilder.start("----------------------------------").color(EnumChatFormatting.GRAY).flush()); sender.addChatMessage(ChatBuilder.start("----------------------------------").color(EnumChatFormatting.GRAY).flush());

View File

@ -22,10 +22,11 @@ public class BoilingHandler extends NEIUniversalHandler {
} }
public static HashMap<Object, Object> cache; public static HashMap<Object, Object> cache;
public static boolean isReload=false;
public static HashMap<Object, Object> generateRecipes() { public static HashMap<Object, Object> generateRecipes() {
if(cache != null) return cache; if(cache != null && !isReload) return cache;
cache = new HashMap(); cache = new HashMap();
@ -40,7 +41,7 @@ public class BoilingHandler extends NEIUniversalHandler {
} }
} }
} }
isReload=false;
return cache; return cache;
} }
} }

View File

@ -14,6 +14,7 @@ import com.google.gson.Gson;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.stream.JsonWriter; import com.google.gson.stream.JsonWriter;
import com.hbm.handler.nei.BoilingHandler;
import com.hbm.handler.pollution.PollutionHandler; import com.hbm.handler.pollution.PollutionHandler;
import com.hbm.handler.pollution.PollutionHandler.PollutionType; import com.hbm.handler.pollution.PollutionHandler.PollutionType;
import com.hbm.inventory.fluid.trait.*; import com.hbm.inventory.fluid.trait.*;
@ -842,7 +843,29 @@ public class Fluids {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
public static void reloadFluids(){
File folder = MainRegistry.configHbmDir;
File customTypes = new File(folder.getAbsolutePath() + File.separatorChar + "hbmFluidTypes.json");
if(!customTypes.exists()) initDefaultFluids(customTypes);
for(FluidType type : customFluids){
idMapping.remove(type.getID());
registerOrder.remove(type);
nameMapping.remove(type.getName());
metaOrder.remove(type);
}
customFluids.clear();
readCustomFluids(customTypes);
for(FluidType custom : customFluids) metaOrder.add(custom);
File config = new File(MainRegistry.configHbmDir.getAbsolutePath() + File.separatorChar + "hbmFluidTraits.json");
File template = new File(MainRegistry.configHbmDir.getAbsolutePath() + File.separatorChar + "_hbmFluidTraits.json");
if(!config.exists()) {
writeDefaultTraits(template);
} else {
readTraits(config);
}
BoilingHandler.isReload=true;
}
private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) { private static void registerCalculatedFuel(FluidType type, double base, double combustMult, FuelGrade grade) {
long flammable = (long) base; long flammable = (long) base;

View File

@ -11,7 +11,7 @@ import net.minecraft.util.EnumChatFormatting;
public class FT_PWRModerator extends FluidTrait { public class FT_PWRModerator extends FluidTrait {
private double multiplier; private double multiplier;
public FT_PWRModerator(){}
public FT_PWRModerator(double mulitplier) { public FT_PWRModerator(double mulitplier) {
this.multiplier = mulitplier; this.multiplier = mulitplier;
} }

View File

@ -11,6 +11,7 @@ import java.util.List;
public class FT_Pheromone extends FluidTrait{ public class FT_Pheromone extends FluidTrait{
public int type; public int type;
public FT_Pheromone() {}
public FT_Pheromone(int type) { public FT_Pheromone(int type) {
this.type = type; this.type = type;