aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gtPlusPlus/xmod/tinkers/HANDLER_Tinkers.java
blob: cd25d068bb0f20014cee014bed544d9df0eaffdb (plain)
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
package gtPlusPlus.xmod.tinkers;

import java.lang.reflect.Field;

import net.minecraft.block.Block;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;

import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.api.objects.data.AutoMap;
import gtPlusPlus.core.lib.LoadedMods;
import gtPlusPlus.core.util.reflect.ReflectionUtils;
import gtPlusPlus.xmod.tinkers.material.BaseTinkersMaterial;
import gtPlusPlus.xmod.tinkers.util.TinkersDryingRecipe;
import gtPlusPlus.xmod.tinkers.util.TinkersUtils;

public class HANDLER_Tinkers {

    public static AutoMap<BaseTinkersMaterial> mTinkerMaterials = new AutoMap<BaseTinkersMaterial>();

    public static final void preInit() {
        if (LoadedMods.TiCon) {}
    }

    public static final void init() {
        if (LoadedMods.TiCon) {}
    }

    public static final void postInit() {
        if (LoadedMods.TiCon) {

            Fluid pyrotheumFluid = FluidRegistry.getFluid("pyrotheum");
            if (pyrotheumFluid != null) {
                // Enable Pyrotheum as Fuel for the Smeltery
                TinkersUtils.addSmelteryFuel(pyrotheumFluid, 5000, 70); // pyrotheum lasts 3.5 seconds per 15 mb
            }

            // Generate Drying Rack recipes
            TinkersDryingRecipe.generateAllDryingRecipes();

            for (BaseTinkersMaterial y : mTinkerMaterials) {
                // y.generate();
            }

            Class aTinkersSmeltery = ReflectionUtils.getClass("tconstruct.smeltery.TinkerSmeltery");
            AutoMap<Fluid> aTweakedFluids = new AutoMap<Fluid>();
            if (aTinkersSmeltery != null) {
                try {
                    Logger.INFO(
                            "Manipulating the light levels of fluids in TiCon. Molten 'metals' in world are now very luminescent!");
                    Field aFluidArrayField = ReflectionUtils.getField(aTinkersSmeltery, "fluids");
                    Field aBlockArrayField = ReflectionUtils.getField(aTinkersSmeltery, "fluidBlocks");
                    Fluid[] aTiconFluids = (Fluid[]) aFluidArrayField.get(null);
                    Block[] aTiconFluidBlocks = (Block[]) aBlockArrayField.get(null);
                    if (aTiconFluids != null && aTiconFluidBlocks != null) {
                        for (Fluid a : aTiconFluids) {
                            if (a == null) {
                                continue;
                            } else {
                                if (a.getLuminosity() <= 15) {
                                    // if (a.getTemperature() >= 500) {
                                    a.setLuminosity(16);
                                    aTweakedFluids.put(a);
                                    // }
                                } else {
                                    aTweakedFluids.put(a);
                                    continue;
                                }
                            }
                        }
                        for (Block a : aTiconFluidBlocks) {
                            if (a == null) {
                                continue;
                            } else {
                                Fluid f = FluidRegistry.lookupFluidForBlock(a);
                                boolean isHot = false;
                                if (f != null && f.getTemperature() >= 500) {
                                    if (f.getLuminosity() <= 16 && !aTweakedFluids.containsValue(f)) {
                                        f.setLuminosity(16);
                                    }
                                    isHot = true;
                                }
                                if (a.getLightValue() <= 16f) {
                                    if (isHot) {
                                        a.setLightLevel(16f);
                                    } else {
                                        if (a.getLightValue() <= 16f) {
                                            a.setLightLevel(16f);
                                        }
                                    }
                                } else {
                                    continue;
                                }
                            }
                        }
                    }
                } catch (IllegalArgumentException | IllegalAccessException e) {}
            }
        }
    }
}