1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
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;
import tectech.loader.recipe.ResearchStationAssemblyLine;
import tectech.loader.thing.CoverLoader;
import tectech.loader.thing.MachineLoader;
import tectech.loader.thing.ThingsLoader;
import tectech.thing.casing.TTCasingsContainer;
import tectech.thing.metaTileEntity.Textures;
@SuppressWarnings("deprecation")
public final class MainLoader {
public static DamageSource microwaving;
private MainLoader() {}
public static void preLoad() {
creativeTabTecTech = new CreativeTabTecTech("TecTech");
// set expanded texture arrays for tiers
try {
Textures.run();
} catch (Throwable t) {
LOGGER.error("Loading textures...", t);
}
}
public static void load() {
ProgressManager.ProgressBar progressBarLoad = ProgressManager.push("TecTech Loader", 6);
progressBarLoad.step("Regular Things");
new ThingsLoader().run();
LOGGER.info("Block/Item Init Done");
progressBarLoad.step("Machine Things");
new MachineLoader().run();
LOGGER.info("Machine Init Done");
progressBarLoad.step("Cover Things");
new CoverLoader().run();
LOGGER.info("Cover Init Done");
progressBarLoad.step("Add damage types");
microwaving = new DamageSource("microwaving").setDamageBypassesArmor();
LOGGER.info("Damage types addition Done");
progressBarLoad.step("Register Packet Dispatcher");
new NetworkDispatcher();
LOGGER.info("Packet Dispatcher registered");
progressBarLoad.step("Register GUI Handler");
proxy.registerRenderInfo();
LOGGER.info("GUI Handler registered");
ProgressManager.pop(progressBarLoad);
}
public static void postLoad() {
ProgressManager.ProgressBar progressBarPostLoad = ProgressManager.push("TecTech Post Loader", 4);
progressBarPostLoad.step("Dreamcraft Compatibility");
if (NewHorizonsCoreMod.isModLoaded()) {
try {
Class<?> clazz = Class.forName("com.dreammaster.gthandler.casings.GT_Container_CasingsNH");
TTCasingsContainer.sBlockCasingsNH = (Block) clazz.getField("sBlockCasingsNH")
.get(null);
if (TTCasingsContainer.sBlockCasingsNH == null) {
throw new NullPointerException("sBlockCasingsNH Is not set at this time");
}
} catch (Exception e) {
throw new Error("Unable to get NH casings", e);
}
}
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() {
new ResearchStationAssemblyLine().runLateRecipes();
}
}
|