From 7caea6daefcbffbc102741ed09daac9d6439824d Mon Sep 17 00:00:00 2001 From: Léa Gris Date: Mon, 5 Sep 2022 17:43:09 +0200 Subject: feat(API): Implements a featured API for GT_Fluid (#1345) * feat(API): Implements a featured API for GT_Fluid *** Rationale The current implementation, which is based on the `GT_Fluid` object, does not allow for the evolution of the functionalities, or the variation of the fluid-related implementations in GregTech. *** Objectives This replacement API should free from these constraints, by providing : 1. The separation of responsibilities of the different tasks and steps: - The definition and progressive construction of an `IGT_Fluid`, - Registration of the `IGT_Fluid`, - Configuration of related equipment, such as containers, - Propagation of properties of an `IGT_Fluid` to related services such as Materials 2. The separation of interfaces exposed to the API from their internal implementations to allow: - Evolve the implementations in the most transparent way possible - To have internal GregTech implementations or outsourced implementations coexist in its extensions. *** Specificity of this new API - Provides a new interface to build and interact with fluid related records - Deprecates the old `api/objects/GT_Fluid` object and the `common/GT_Proxy.addFluid` record methods * fix(conversations): addresses @Glease review comments https://github.com/GTNewHorizons/GT5-Unofficial/pull/1345#pullrequestreview-1096261703 * ./gradlew :spotlessApply * fix(review): add review comments from @eigenraven Added missing final qualifiers on methods parameters. https://github.com/GTNewHorizons/GT5-Unofficial/pull/1345#pullrequestreview-1096318523 * fix(review) address remaining review comments from @eigenraven --- src/main/java/gregtech/api/enums/FluidState.java | 10 ++++++++++ src/main/java/gregtech/api/enums/Materials.java | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 src/main/java/gregtech/api/enums/FluidState.java (limited to 'src/main/java/gregtech/api/enums') diff --git a/src/main/java/gregtech/api/enums/FluidState.java b/src/main/java/gregtech/api/enums/FluidState.java new file mode 100644 index 0000000000..ad27047a1c --- /dev/null +++ b/src/main/java/gregtech/api/enums/FluidState.java @@ -0,0 +1,10 @@ +package gregtech.api.enums; + +public enum FluidState { + GAS, + LIQUID, + MOLTEN, + PLASMA, + SLURRY; + public static final FluidState[] VALUES = new FluidState[] {SLURRY, LIQUID, GAS, PLASMA, MOLTEN}; +} diff --git a/src/main/java/gregtech/api/enums/Materials.java b/src/main/java/gregtech/api/enums/Materials.java index 80af9add86..fc254b55cf 100644 --- a/src/main/java/gregtech/api/enums/Materials.java +++ b/src/main/java/gregtech/api/enums/Materials.java @@ -1,5 +1,6 @@ package gregtech.api.enums; +import static gregtech.api.enums.FluidState.GAS; import static gregtech.api.enums.GT_Values.M; import static gregtech.api.enums.GT_Values.MOD_ID_DC; @@ -7,6 +8,7 @@ import cpw.mods.fml.common.Loader; import gregtech.GT_Mod; import gregtech.api.GregTech_API; import gregtech.api.enums.TC_Aspects.TC_AspectStack; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.interfaces.IColorModulationContainer; import gregtech.api.interfaces.IMaterialHandler; import gregtech.api.interfaces.ISubTagContainer; @@ -2604,8 +2606,8 @@ public class Materials implements IColorModulationContainer, ISubTagContainer { } aMaterial.mHasGas = GregTech_API.sMaterialProperties.get(aConfigPath, "AddGas", aMaterial.mHasGas); if (aMaterial.mHasGas) { - GT_Mod.gregtechproxy.addFluid( - aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName, aMaterial, 2, aMaterial.mGasTemp); + GT_FluidFactory.of( + aMaterial.mName.toLowerCase(), aMaterial.mDefaultLocalName, aMaterial, GAS, aMaterial.mGasTemp); } } } -- cgit