blob: 291cdf33844b3bac49ee25f9cc4ccb9ebbb27f41 (
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
|
package gregtech.api.fluid;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import gregtech.api.enums.FluidState;
import gregtech.api.enums.Materials;
import gregtech.api.interfaces.fluid.IGTFluid;
import gregtech.api.interfaces.fluid.IGTFluidBuilder;
import gregtech.common.fluid.GTFluidBuilder;
/**
* <p>
* This class contains helpers factory methods to:
* </p>
* <ol>
* <li>
* <p>
* Build {@link IGTFluid} instances.
* </p>
* </li>
* <li>
* <p>
* Register the corresponding {@link Fluid}, built from an {@link IGTFluid}, 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 GTFluidFactory {
/**
* 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 IGTFluid}
* @param material The {@link Materials} of this {@link IGTFluid}
* @param state The {@link FluidState} of this {@link IGTFluid}
* @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 IGTFluid}
* @param state The {@link FluidState} of this {@link IGTFluid}
* @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 IGTFluid} builder instance
*
* @param fluidName The name key of the {@link Fluid} to register in the {@link FluidRegistry}
* @return the {@link IGTFluidBuilder} instance
*/
public static IGTFluidBuilder builder(final String fluidName) {
return new GTFluidBuilder(fluidName);
}
}
|