Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/config/tectech' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Dream-Master committed Sep 18, 2024
2 parents 7716689 + af2996f commit 6ca0d39
Show file tree
Hide file tree
Showing 15 changed files with 167 additions and 542 deletions.
32 changes: 12 additions & 20 deletions src/main/java/tectech/TecTech.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,21 @@

import net.minecraftforge.common.MinecraftForge;

import com.gtnewhorizon.gtnhlib.config.ConfigException;
import com.gtnewhorizon.gtnhlib.config.ConfigurationManager;

import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLLoadCompleteEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import eu.usrv.yamcore.auxiliary.IngameErrorLog;
import eu.usrv.yamcore.auxiliary.LogHelper;
import gregtech.api.enums.Mods;
import gregtech.api.objects.XSTR;
import tectech.loader.ConfigHandler;
import tectech.loader.MainLoader;
import tectech.loader.TecTechConfig;
import tectech.loader.gui.CreativeTabTecTech;
import tectech.loader.thing.MuTeLoader;
import tectech.mechanics.enderStorage.EnderWorldSavedData;
Expand All @@ -26,6 +28,7 @@
modid = Reference.MODID,
name = Reference.NAME,
version = Reference.VERSION,
guiFactory = "tectech.loader.gui.TecTechGUIFactory",
dependencies = "required-after:Forge@[10.13.4.1614,);" + "required-after:YAMCore@[0.5.70,);"
+ "required-after:structurelib;"
+ "after:ComputerCraft;"
Expand All @@ -38,6 +41,13 @@
+ "after:Thaumcraft;")
public class TecTech {

static {
try {
ConfigurationManager.registerConfig(ConfigHandler.class);
} catch (ConfigException e) {
throw new RuntimeException(e);
}
}
@SidedProxy(clientSide = Reference.CLIENTSIDE, serverSide = Reference.SERVERSIDE)
public static CommonProxy proxy;

Expand All @@ -48,8 +58,6 @@ public class TecTech {
public static final LogHelper LOGGER = new LogHelper(Reference.MODID);
public static CreativeTabTecTech creativeTabTecTech;

public static TecTechConfig configTecTech;

public static EnderWorldSavedData enderWorldSavedData;

/**
Expand All @@ -64,21 +72,6 @@ public class TecTech {
public void PreLoad(FMLPreInitializationEvent PreEvent) {
LOGGER.setDebugOutput(true);

configTecTech = new TecTechConfig(
PreEvent.getModConfigurationDirectory(),
Reference.COLLECTIONNAME,
Reference.MODID);

if (!configTecTech.LoadConfig()) {
LOGGER.error(Reference.MODID + " could not load its config file. Things are going to be weird!");
}

if (configTecTech.MOD_ADMIN_ERROR_LOGS) {
LOGGER.setDebugOutput(TecTechConfig.DEBUG_MODE);
LOGGER.debug("moduleAdminErrorLogs is enabled");
IngameErrorLog moduleAdminErrorLogs = new IngameErrorLog();
}

enderWorldSavedData = new EnderWorldSavedData();
FMLCommonHandler.instance()
.bus()
Expand All @@ -97,7 +90,6 @@ public void Load(FMLInitializationEvent event) {
hasCOFH = Mods.COFHCore.isModLoaded();

MainLoader.load();
MainLoader.addAfterGregTechPostLoadRunner();
}

@Mod.EventHandler
Expand Down
61 changes: 61 additions & 0 deletions src/main/java/tectech/loader/ConfigHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package tectech.loader;

import com.gtnewhorizon.gtnhlib.config.Config;

import gregtech.api.enums.Mods;

@Config(modid = Mods.Names.TECTECH, filename = "tectech")
@Config.LangKeyPattern(pattern = "GT5U.gui.config.%cat.%field", fullyQualified = true)
@Config.RequiresMcRestart
public class ConfigHandler {

public static Debug debug = new Debug();
public static TeslaTweaks teslaTweaks = new TeslaTweaks();

@Config.Comment("Debug section")
public static class Debug {

@Config.Comment("Enables logging and other purely debug features")
@Config.DefaultBoolean(false)
public boolean DEBUG_MODE;
}

@Config.Comment("Tesla tweaks section")
public static class TeslaTweaks {

@Config.Ignore()
public static final float TESLA_MULTI_LOSS_FACTOR_OVERDRIVE = 0.25f;
@Config.Ignore()
public static final int TESLA_MULTI_LOSS_PER_BLOCK_T0 = 1;
@Config.Ignore()
public static final int TESLA_MULTI_LOSS_PER_BLOCK_T1 = 1;
@Config.Ignore()
public static final int TESLA_MULTI_LOSS_PER_BLOCK_T2 = 1;
@Config.Ignore()
public static final int TESLA_MULTI_PLASMA_PER_SECOND_T1_HELIUM = 100;
@Config.Ignore()
public static final int TESLA_MULTI_PLASMA_PER_SECOND_T1_NITROGEN = 50;
@Config.Ignore()
public static final int TESLA_MULTI_PLASMA_PER_SECOND_T2_RADON = 50;
@Config.Ignore()
public static final int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T1 = 2;
@Config.Ignore()
public static final int TESLA_MULTI_RANGE_COEFFICIENT_PLASMA_T2 = 4;
@Config.Ignore()
public static final int TESLA_MULTI_RANGE_COVER = 16;
@Config.Ignore()
public static final int TESLA_MULTI_RANGE_TOWER = 32;
@Config.Ignore()
public static final int TESLA_MULTI_RANGE_TRANSCEIVER = 16;
@Config.Ignore()
public static final float TESLA_SINGLE_LOSS_FACTOR_OVERDRIVE = 0.25f;
@Config.Ignore()
public static final int TESLA_SINGLE_LOSS_PER_BLOCK = 1;

@Config.Ignore()
public static final int TESLA_SINGLE_RANGE = 20;
@Config.Comment("Set true to enable the cool visual effect when tesla tower running.")
@Config.DefaultBoolean(true)
public boolean TESLA_VISUAL_EFFECT;
}
}
112 changes: 1 addition & 111 deletions src/main/java/tectech/loader/MainLoader.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
package tectech.loader;

import static gregtech.api.enums.Mods.NewHorizonsCoreMod;
import static gregtech.api.enums.Mods.TwilightForest;
import static tectech.TecTech.LOGGER;
import static tectech.TecTech.configTecTech;
import static tectech.TecTech.creativeTabTecTech;
import static tectech.TecTech.proxy;
import static tectech.loader.TecTechConfig.DEBUG_MODE;

import java.util.HashMap;

import net.minecraft.block.Block;
import net.minecraft.util.DamageSource;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;

import cpw.mods.fml.common.ProgressManager;
import cpw.mods.fml.common.registry.GameRegistry;
import gregtech.api.GregTechAPI;
import gregtech.api.enums.Materials;
import gregtech.api.recipe.RecipeMaps;
import gregtech.api.util.GTRecipe;
import tectech.TecTech;
import tectech.loader.gui.CreativeTabTecTech;
import tectech.loader.recipe.BaseRecipeLoader;
Expand Down Expand Up @@ -80,7 +68,7 @@ public static void load() {
}

public static void postLoad() {
ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 4);
ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 2);

progressBarPostLoad.step("Dreamcraft Compatibility");
if (NewHorizonsCoreMod.isModLoaded()) {
Expand All @@ -100,104 +88,6 @@ public static void postLoad() {
progressBarPostLoad.step("Recipes");
new BaseRecipeLoader().run();
TecTech.LOGGER.info("Recipe Init Done");

if (!configTecTech.DISABLE_BLOCK_HARDNESS_NERF) {
progressBarPostLoad.step("Nerf blocks blast resistance");
adjustTwilightBlockResistance();
TecTech.LOGGER.info("Blocks nerf done");
} else {
progressBarPostLoad.step("Do not nerf blocks blast resistance");
TecTech.LOGGER.info("Blocks were not nerfed");
}

// ProgressManager.pop(progressBarPostLoad);
}

public static void addAfterGregTechPostLoadRunner() {
GregTechAPI.sAfterGTPostload.add(() -> {
if (TecTech.configTecTech.NERF_FUSION) {
FixBrokenFusionRecipes();
}
});
}

private static void FixBrokenFusionRecipes() {
HashMap<Fluid, Fluid> binds = new HashMap<>();
for (Materials material : Materials.values()) {
FluidStack p = material.getPlasma(1);
if (p != null) {
if (DEBUG_MODE) {
LOGGER.info("Found Plasma of " + material.mName);
}
if (material.mElement != null && (material.mElement.mProtons >= Materials.Iron.mElement.mProtons
|| -material.mElement.mProtons >= Materials.Iron.mElement.mProtons
|| material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons
|| -material.mElement.mNeutrons >= Materials.Iron.mElement.mNeutrons)) {
if (DEBUG_MODE) {
LOGGER.info("Attempting to bind " + material.mName);
}
if (material.getMolten(1) != null) {
binds.put(
p.getFluid(),
material.getMolten(1)
.getFluid());
} else if (material.getGas(1) != null) {
binds.put(
p.getFluid(),
material.getGas(1)
.getFluid());
} else if (material.getFluid(1) != null) {
binds.put(
p.getFluid(),
material.getFluid(1)
.getFluid());
} else {
binds.put(
p.getFluid(),
Materials.Iron.getMolten(1)
.getFluid());
}
}
}
}
for (GTRecipe r : RecipeMaps.fusionRecipes.getAllRecipes()) {
Fluid fluid = binds.get(r.mFluidOutputs[0].getFluid());
if (fluid != null) {
if (DEBUG_MODE) {
LOGGER.info("Nerfing Recipe " + r.mFluidOutputs[0].getUnlocalizedName());
}
r.mFluidOutputs[0] = new FluidStack(fluid, r.mFluidOutputs[0].amount);
}
fluid = binds.get(r.mFluidInputs[0].getFluid());
if (fluid != null) {
if (DEBUG_MODE) {
LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[0].getUnlocalizedName());
}
r.mFluidInputs[0] = new FluidStack(fluid, r.mFluidInputs[0].amount);
}
fluid = binds.get(r.mFluidInputs[1].getFluid());
if (fluid != null) {
if (DEBUG_MODE) {
LOGGER.info("Fixing plasma use in Recipe " + r.mFluidInputs[1].getUnlocalizedName());
}
r.mFluidInputs[1] = new FluidStack(fluid, r.mFluidInputs[1].amount);
}
}
}

private static void safeSetResistance(Block block, float resistance) {
if (block != null) {
block.setResistance(resistance);
}
}

private static void adjustTwilightBlockResistance() {
if (TwilightForest.isModLoaded()) {
safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFShield"), 30);
safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFThorns"), 10);
safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFTowerTranslucent"), 30);
safeSetResistance(GameRegistry.findBlock("TwilightForest", "tile.TFDeadrock"), 5);
}
}

public static void onLoadCompleted() {
Expand Down
Loading

0 comments on commit 6ca0d39

Please sign in to comment.