aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/fluid/GT_FluidFactory.java
blob: 1622aa2e05295ee5ec19fdc5a8b0840a114b2263 (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
package gregtech.api.fluid;

import gregtech.api.enums.FluidState;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.fluid.IGT_Fluid;
import gregtech.api.interfaces.fluid.IGT_FluidBuilder;
import gregtech.common.fluid.GT_FluidBuilder;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;

/**
 * <p>This class contains helpers factory methods to:</p>
 * <ol>
 *     <li>
 *         <p>Build {@link IGT_Fluid} instances.</p>
 *     </li>
 *     <li>
 *         <p>Register the corresponding {@link Fluid}, built from an {@link IGT_Fluid},
 *         to the {@link FluidRegistry}:</p>
 *         <ul>
 *             <li>
 *                 <p>Register the optionally associated containers to the {@link FluidContainerRegistry}.</p>
 *             </li>
 *             <li>
 *             <p>Add the needed Fluid Canner recipes.</p>
 *             </li>
 *         </ul>
 *     </li>
 * </ol>
 */
@SuppressWarnings("unused") // API might legitimately expose unused methods within this local project's scope
public class GT_FluidFactory {

    /**
     * Helper for quick fluid creation and registration
     * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry}
     * @param localizedName The localized name of this {@link IGT_Fluid}
     * @param material The {@link Materials} of this {@link IGT_Fluid}
     * @param state The {@link FluidState} of this {@link IGT_Fluid}
     * @param temperature The fluid temperature in Kelvin
     * @return the registered {@link Fluid}
     */
    public static Fluid of(
            final String fluidName,
            final String localizedName,
            final Materials material,
            final FluidState state,
            final int temperature) {
        return builder(fluidName)
                .withLocalizedName(localizedName)
                .withStateAndTemperature(state, temperature)
                .buildAndRegister()
                .configureMaterials(material)
                .asFluid();
    }

    /**
     * Helper for quick fluid creation and registration
     * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry}
     * @param localizedName The localized name of this {@link IGT_Fluid}
     * @param state The {@link FluidState} of this {@link IGT_Fluid}
     * @param temperature The fluid temperature in Kelvin
     * @return the registered {@link Fluid}
     */
    public static Fluid of(
            final String fluidName, final String localizedName, final FluidState state, final int temperature) {
        return builder(fluidName)
                .withLocalizedName(localizedName)
                .withStateAndTemperature(state, temperature)
                .buildAndRegister()
                .asFluid();
    }

    /**
     * Gets an {@link IGT_Fluid} builder instance
     * @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry}
     * @return the {@link IGT_FluidBuilder} instance
     */
    public static IGT_FluidBuilder builder(final String fluidName) {
        return new GT_FluidBuilder(fluidName);
    }
}