diff options
author | Léa Gris <lea.gris@noiraude.net> | 2022-09-05 17:43:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-05 17:43:09 +0200 |
commit | 7caea6daefcbffbc102741ed09daac9d6439824d (patch) | |
tree | d223491481aeafd36418a62cb43250703b1cc987 /src/main/java/gregtech/common | |
parent | f97a1861751aa9431a7c36eb4ea061f902e9f255 (diff) | |
download | GT5-Unofficial-7caea6daefcbffbc102741ed09daac9d6439824d.tar.gz GT5-Unofficial-7caea6daefcbffbc102741ed09daac9d6439824d.tar.bz2 GT5-Unofficial-7caea6daefcbffbc102741ed09daac9d6439824d.zip |
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
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r-- | src/main/java/gregtech/common/GT_Proxy.java | 178 | ||||
-rw-r--r-- | src/main/java/gregtech/common/fluid/GT_Fluid.java | 207 | ||||
-rw-r--r-- | src/main/java/gregtech/common/fluid/GT_FluidBuilder.java | 133 |
3 files changed, 439 insertions, 79 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java index 0a529cfa3b..3fb7bdd337 100644 --- a/src/main/java/gregtech/common/GT_Proxy.java +++ b/src/main/java/gregtech/common/GT_Proxy.java @@ -1,6 +1,10 @@ package gregtech.common; import static gregtech.GT_Mod.GT_FML_LOGGER; +import static gregtech.api.enums.FluidState.GAS; +import static gregtech.api.enums.FluidState.LIQUID; +import static gregtech.api.enums.FluidState.MOLTEN; +import static gregtech.api.enums.FluidState.PLASMA; import static gregtech.api.enums.GT_Values.MOD_ID_RC; import static gregtech.api.enums.GT_Values.MOD_ID_TC; import static gregtech.api.enums.GT_Values.MOD_ID_TE; @@ -25,6 +29,7 @@ import forestry.api.genetics.AlleleManager; import gregtech.api.GregTech_API; import gregtech.api.enums.ConfigCategories; import gregtech.api.enums.Dyes; +import gregtech.api.enums.FluidState; import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; @@ -34,9 +39,11 @@ import gregtech.api.enums.SoundResource; import gregtech.api.enums.SubTag; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.enums.ToolDictNames; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.interfaces.IBlockOnWalkOver; import gregtech.api.interfaces.IGlobalWirelessEnergy; import gregtech.api.interfaces.IProjectileItem; +import gregtech.api.interfaces.fluid.IGT_Fluid; import gregtech.api.interfaces.internal.IGT_Mod; import gregtech.api.interfaces.internal.IThaumcraftCompat; import gregtech.api.interfaces.metatileentity.IMetaTileEntity; @@ -2456,75 +2463,76 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG // If the fluid is registered as custom inside the Material's constructor then to add custom fluid // textures go to blocks/fluids and place the .png. File should be called fluid.fluid.{unlocalised_name}.png. // All lower case. - String fluidTexture = - aMaterial.mIconSet.is_custom ? ("fluid." + aMaterial.mName.toLowerCase()) : "autogenerated"; - return addFluid( - aMaterial.mName.toLowerCase(Locale.ENGLISH), - fluidTexture, - aMaterial.mDefaultLocalName, - aMaterial, - aMaterial.mRGBa, - 1, - aMaterial.getLiquidTemperature(), - GT_OreDictUnificator.get(OrePrefixes.cell, aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - 1000); + final String fluidTexture = + aMaterial.mIconSet.is_custom ? "fluid." + aMaterial.mName.toLowerCase() : "autogenerated"; + return GT_FluidFactory.builder(aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withLocalizedName(aMaterial.mDefaultLocalName) + .withTextureName(fluidTexture) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(LIQUID, aMaterial.getLiquidTemperature()) + .buildAndRegister() + .configureMaterials(aMaterial) + .registerBContainers( + GT_OreDictUnificator.get(OrePrefixes.cell, aMaterial, 1L), ItemList.Cell_Empty.get(1L)) + .asFluid(); } public Fluid addAutoGeneratedCorrespondingGas(Materials aMaterial) { // If the fluid is registered as custom inside the Material's constructor then to add custom fluid // textures go to blocks/fluids and place the .png. File should be called fluid.gas.{unlocalised_name}.png. All // lower case. - String fluidTexture = aMaterial.mIconSet.is_custom ? ("gas." + aMaterial.mName.toLowerCase()) : "autogenerated"; - return addFluid( - aMaterial.mName.toLowerCase(Locale.ENGLISH), - fluidTexture, - aMaterial.mDefaultLocalName, - aMaterial, - aMaterial.mRGBa, - 2, - aMaterial.getGasTemperature(), - GT_OreDictUnificator.get(OrePrefixes.cell, aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - 1000); + final String fluidTexture = + aMaterial.mIconSet.is_custom ? ("gas." + aMaterial.mName.toLowerCase()) : "autogenerated"; + return GT_FluidFactory.builder(aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withLocalizedName(aMaterial.mDefaultLocalName) + .withTextureName(fluidTexture) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(GAS, aMaterial.getGasTemperature()) + .buildAndRegister() + .configureMaterials(aMaterial) + .registerBContainers( + GT_OreDictUnificator.get(OrePrefixes.cell, aMaterial, 1L), ItemList.Cell_Empty.get(1L)) + .asFluid(); } public Fluid addAutogeneratedPlasmaFluid(Materials aMaterial) { // If the fluid is registered as custom inside the Material's constructor then to add custom fluid // textures go to blocks/fluids and place the .png. File should be called fluid.plasma.{unlocalised_name}.png. // All lower case. - String fluidTexture = + final String fluidTexture = aMaterial.mIconSet.is_custom ? ("plasma." + aMaterial.mName.toLowerCase()) : "plasma.autogenerated"; - return addFluid( - "plasma." + aMaterial.mName.toLowerCase(Locale.ENGLISH), - fluidTexture, - aMaterial.mDefaultLocalName + " Plasma", - aMaterial, - aMaterial.mMoltenRGBa, - 3, - 10000, - GT_OreDictUnificator.get(OrePrefixes.cellPlasma, aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - aMaterial.getMolten(1) != null ? 144 : 1000); + return GT_FluidFactory.builder("plasma." + aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withLocalizedName(aMaterial.mDefaultLocalName + " Plasma") + .withTextureName(fluidTexture) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(PLASMA, 10000) + .buildAndRegister() + .configureMaterials(aMaterial) + .registerContainers( + GT_OreDictUnificator.get(OrePrefixes.cellPlasma, aMaterial, 1L), + ItemList.Cell_Empty.get(1L), + aMaterial.getMolten(1) != null ? 144 : 1000) + .asFluid(); } public Fluid addAutogeneratedMoltenFluid(Materials aMaterial) { // If the fluid is registered as custom inside the Material's constructor then to add custom fluid // textures go to blocks/fluids and place the .png. File should be called fluid.molten.{unlocalised_name}.png. // All lower case. - String fluidTexture = + final String fluidTexture = aMaterial.mIconSet.is_custom ? ("molten." + aMaterial.mName.toLowerCase()) : "molten.autogenerated"; - return addFluid( - "molten." + aMaterial.mName.toLowerCase(Locale.ENGLISH), - fluidTexture, - "Molten " + aMaterial.mDefaultLocalName, - aMaterial, - aMaterial.mMoltenRGBa, - 4, - aMaterial.mMeltingPoint < 0 ? 1000 : aMaterial.mMeltingPoint, - GT_OreDictUnificator.get(OrePrefixes.cellMolten, aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - 144); + return GT_FluidFactory.builder("molten." + aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withLocalizedName("Molten " + aMaterial.mDefaultLocalName) + .withTextureName(fluidTexture) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(MOLTEN, aMaterial.mMeltingPoint < 0 ? 1000 : aMaterial.mMeltingPoint) + .buildAndRegister() + .configureMaterials(aMaterial) + .registerContainers( + GT_OreDictUnificator.get(OrePrefixes.cellMolten, aMaterial, 1L), + ItemList.Cell_Empty.get(1L), + 144) + .asFluid(); } // ------------------------------------------------------------------------------------------------------------ @@ -2535,24 +2543,22 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG OrePrefixes[] orePrefixes = { OrePrefixes.cellHydroCracked1, OrePrefixes.cellHydroCracked2, OrePrefixes.cellHydroCracked3 }; - GT_Fluid uncrackedFluid = null; + final Fluid uncrackedFluid; if (aMaterial.mFluid != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mFluid; + uncrackedFluid = aMaterial.mFluid; } else if (aMaterial.mGas != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mGas; - } + uncrackedFluid = aMaterial.mGas; + } else return; for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid( - namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), - uncrackedFluid.mTextureName, - orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, - null, - aMaterial.mRGBa, - 2, - 775, - GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - 1000); + crackedFluids[i] = GT_FluidFactory.builder(namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withTextureFrom((IGT_Fluid) uncrackedFluid) + .withLocalizedName(orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(GAS, 775) + .buildAndRegister() + .registerBContainers( + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), ItemList.Cell_Empty.get(1L)) + .asFluid(); int hydrogenAmount = 2 * i + 2; GT_Values.RA.addCrackingRecipe( @@ -2588,24 +2594,22 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG OrePrefixes[] orePrefixes = { OrePrefixes.cellSteamCracked1, OrePrefixes.cellSteamCracked2, OrePrefixes.cellSteamCracked3 }; - GT_Fluid uncrackedFluid = null; + final Fluid uncrackedFluid; if (aMaterial.mFluid != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mFluid; + uncrackedFluid = aMaterial.mFluid; } else if (aMaterial.mGas != null) { - uncrackedFluid = (GT_Fluid) aMaterial.mGas; - } + uncrackedFluid = aMaterial.mGas; + } else return; for (int i = 0; i < 3; i++) { - crackedFluids[i] = addFluid( - namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH), - uncrackedFluid.mTextureName, - orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName, - null, - aMaterial.mRGBa, - 2, - 775, - GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), - ItemList.Cell_Empty.get(1L), - 1000); + crackedFluids[i] = GT_FluidFactory.builder(namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH)) + .withTextureFrom((IGT_Fluid) uncrackedFluid) + .withLocalizedName(orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName) + .withColorRGBA(aMaterial.mRGBa) + .withStateAndTemperature(GAS, 775) + .buildAndRegister() + .registerBContainers( + GT_OreDictUnificator.get(orePrefixes[i], aMaterial, 1L), ItemList.Cell_Empty.get(1L)) + .asFluid(); GT_Values.RA.addCrackingRecipe( i + 1, @@ -2634,10 +2638,21 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG aMaterial.setSteamCrackedFluids(crackedFluids); } + /** + * @deprecated use {@link IGT_Fluid#addFluid} + * @see GT_FluidFactory#of(String, String, Materials, FluidState, int) + * @see GT_FluidFactory#of(String, String, FluidState, int) + */ + @Deprecated public Fluid addFluid(String aName, String aLocalized, Materials aMaterial, int aState, int aTemperatureK) { return addFluid(aName, aLocalized, aMaterial, aState, aTemperatureK, null, null, 0); } + /** + * @deprecated use {@link IGT_Fluid#addFluid} + * @see GT_FluidFactory#builder + */ + @Deprecated public Fluid addFluid( String aName, String aLocalized, @@ -2660,6 +2675,11 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG aFluidAmount); } + /** + * @deprecated use {@link IGT_Fluid#addFluid} + * @see GT_FluidFactory#builder + */ + @Deprecated public Fluid addFluid( String aName, String aTexture, diff --git a/src/main/java/gregtech/common/fluid/GT_Fluid.java b/src/main/java/gregtech/common/fluid/GT_Fluid.java new file mode 100644 index 0000000000..4e4131bb2f --- /dev/null +++ b/src/main/java/gregtech/common/fluid/GT_Fluid.java @@ -0,0 +1,207 @@ +package gregtech.common.fluid; + +import gregtech.api.GregTech_API; +import gregtech.api.enums.FluidState; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.Materials; +import gregtech.api.interfaces.fluid.IGT_Fluid; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable { + private final String localizedName; + private final ResourceLocation stillIconResourceLocation; + private final ResourceLocation flowingIconResourceLocation; + private final short[] colorRGBA; + private final FluidState fluidState; + private final int temperature; + + /** + * Constructs this {@link IGT_Fluid} implementation from an {@link GT_FluidBuilder} instance + * + * @param builder The {@link GT_FluidBuilder} instance to construct this {@link IGT_Fluid} implementation + */ + protected GT_Fluid(final GT_FluidBuilder builder) { + super(builder.fluidName); + this.localizedName = builder.localizedName; + this.stillIconResourceLocation = builder.stillIconResourceLocation; + this.flowingIconResourceLocation = builder.flowingIconResourceLocation; + this.block = builder.fluidBlock; + this.colorRGBA = builder.colorRGBA; + this.fluidState = builder.fluidState; + this.temperature = builder.temperature; + configureFromStateTemperature(); + } + + /** + * @inheritDoc from {@link Fluid#getColor()} + */ + @Override + public int getColor() { + return (Math.max(0, Math.min(255, colorRGBA[0])) << 16) + | (Math.max(0, Math.min(255, colorRGBA[1])) << 8) + | Math.max(0, Math.min(255, colorRGBA[2])); + } + + /** + * This {@link Runnable#run()} implementation is scheduled within the {@link GregTech_API#sGTBlockIconload} + * to load this {@link IGT_Fluid}'s texture icons. + * + * @inheritDoc from {@link Runnable#run()} + */ + @Override + public void run() { + final IIcon stillIcon = GregTech_API.sBlockIcons.registerIcon(stillIconResourceLocation.toString()); + if (flowingIconResourceLocation == null) { + setIcons(stillIcon); + } else { + final IIcon flowingIcon = GregTech_API.sBlockIcons.registerIcon(flowingIconResourceLocation.toString()); + setIcons(stillIcon, flowingIcon); + } + } + + /** + * @inheritDoc from {@link IGT_Fluid#addFluid()} + */ + @Override + public IGT_Fluid addFluid() { + // Adds self the block icons loader run() tasks + GregTech_API.sGTBlockIconload.add(this); + GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(), localizedName); + + final Fluid registeredFluid = registerFluid(); + if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) { + registeredFluid.setTemperature(temperature); + } + return this; + } + + /** + * @inheritDoc from {@link IGT_Fluid#registerContainers(ItemStack, ItemStack, int)} + */ + @Override + public IGT_Fluid registerContainers( + final ItemStack fullContainer, final ItemStack emptyContainer, final int containerSize) { + if (fullContainer == null || emptyContainer == null) return this; + final FluidStack fluidStack = new FluidStack(this, containerSize); + if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) { + GT_Values.RA.addFluidCannerRecipe( + fullContainer, GT_Utility.getContainerItem(fullContainer, false), null, fluidStack); + } + return this; + } + + /** + * @inheritDoc from {@link IGT_Fluid#registerBContainers(ItemStack, ItemStack)} + */ + @Override + public IGT_Fluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { + return registerContainers(fullContainer, emptyContainer, 1000); + } + + /** + * @inheritDoc from {@link IGT_Fluid#registerPContainers(ItemStack, ItemStack)} + */ + @Override + public IGT_Fluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) { + return registerContainers(fullContainer, emptyContainer, 250); + } + + /** + * @inheritDoc from {@link IGT_Fluid#getStillIconResourceLocation()} + */ + @Override + public ResourceLocation getStillIconResourceLocation() { + return stillIconResourceLocation; + } + + /** + * @inheritDoc from {@link IGT_Fluid#getFlowingIconResourceLocation()} + */ + @Override + public ResourceLocation getFlowingIconResourceLocation() { + return flowingIconResourceLocation; + } + + /** + * @throws IllegalStateException if {@link FluidState} in invalid + * @inheritDoc from {@link IGT_Fluid#configureMaterials(Materials)} + */ + @Override + public IGT_Fluid configureMaterials(final Materials material) { + switch (fluidState) { + case SLURRY: + material.mSolid = this; + break; + case LIQUID: + material.mFluid = this; + break; + case GAS: + material.mGas = this; + break; + case PLASMA: + material.mPlasma = this; + break; + case MOLTEN: + material.mStandardMoltenFluid = this; + break; + default: + throw new IllegalStateException("Unexpected FluidState: " + fluidState); + } + return this; + } + + /** + * @inheritDoc from {@link IGT_Fluid#asFluid()} + */ + @Override + public Fluid asFluid() { + return this; + } + + /** + * Adjusts this {@link Fluid}'s settings based on this {@link IGT_Fluid}'s state + * + * @throws IllegalStateException if {@link FluidState} in invalid + */ + protected void configureFromStateTemperature() { + switch (fluidState) { + case SLURRY: // Solid + setGaseous(false).setViscosity(10000); + break; + case LIQUID: // Fluid + case MOLTEN: // Molten + setGaseous(false) + .setViscosity(1000) + .setLuminosity( + temperature >= 5000 + ? 15 + : temperature < 1000 ? 0 : 14 * (temperature - 1000) / 4000 + 1); + break; + case GAS: // Gas + setGaseous(true).setDensity(-100).setViscosity(200); + break; + case PLASMA: // Plasma + setGaseous(true).setDensity(55536).setViscosity(10).setLuminosity(15); + break; + default: + throw new IllegalStateException("Unexpected FluidState: " + fluidState); + } + } + + /** + * Registers this {@link IGT_Fluid} to the {@link FluidRegistry} + * + * @return the {@link Fluid} from the {@link FluidRegistry} + */ + protected Fluid registerFluid() { + return FluidRegistry.registerFluid(this) ? this : FluidRegistry.getFluid(this.fluidName); + } +} diff --git a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java new file mode 100644 index 0000000000..91db377ce0 --- /dev/null +++ b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java @@ -0,0 +1,133 @@ +package gregtech.common.fluid; + +import static gregtech.api.enums.GT_Values.MOD_ID; + +import gregtech.api.enums.Dyes; +import gregtech.api.enums.FluidState; +import gregtech.api.interfaces.fluid.IGT_Fluid; +import gregtech.api.interfaces.fluid.IGT_FluidBuilder; +import java.util.Locale; +import net.minecraft.block.Block; +import net.minecraft.util.ResourceLocation; + +public class GT_FluidBuilder implements IGT_FluidBuilder { + protected final String fluidName; + protected String localizedName; + protected ResourceLocation stillIconResourceLocation = null, flowingIconResourceLocation = null; + protected short[] colorRGBA = Dyes._NULL.getRGBA(); + protected Block fluidBlock = null; + protected FluidState fluidState; + protected int temperature; + + public GT_FluidBuilder(final String fluidName) { + this.fluidName = fluidName; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withColorRGBA(short[])} + */ + @Override + public IGT_FluidBuilder withColorRGBA(final short[] colorRGBA) { + this.colorRGBA = colorRGBA; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withLocalizedName(String)} + */ + @Override + public IGT_FluidBuilder withLocalizedName(final String localizedName) { + this.localizedName = localizedName; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withStateAndTemperature(FluidState, int)} + */ + @Override + public IGT_FluidBuilder withStateAndTemperature(final FluidState fluidState, final int temperature) { + this.fluidState = fluidState; + this.temperature = temperature; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withStillIconResourceLocation(ResourceLocation)} + */ + @Override + public IGT_FluidBuilder withStillIconResourceLocation(final ResourceLocation stillIconResourceLocation) { + this.stillIconResourceLocation = stillIconResourceLocation; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withFlowingIconResourceLocation(ResourceLocation)} + */ + @Override + public IGT_FluidBuilder withFlowingIconResourceLocation(final ResourceLocation flowingIconResourceLocation) { + this.flowingIconResourceLocation = flowingIconResourceLocation; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withTextureName(String)} + */ + @Override + public IGT_FluidBuilder withTextureName(final String textureName) { + this.stillIconResourceLocation = new ResourceLocation(MOD_ID, "fluids/fluid." + textureName); + this.flowingIconResourceLocation = null; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withTextureFrom(IGT_Fluid)} + */ + @Override + public IGT_FluidBuilder withTextureFrom(final IGT_Fluid fromGTFluid) { + this.stillIconResourceLocation = fromGTFluid.getStillIconResourceLocation(); + this.flowingIconResourceLocation = fromGTFluid.getFlowingIconResourceLocation(); + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withFluidBlock} + */ + @Override + public IGT_FluidBuilder withFluidBlock(final Block fluidBlock) { + this.fluidBlock = fluidBlock; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#withTextures(ResourceLocation, ResourceLocation)} + */ + @Override + public IGT_FluidBuilder withTextures( + final ResourceLocation stillIconResourceLocation, final ResourceLocation flowingIconResourceLocation) { + this.stillIconResourceLocation = stillIconResourceLocation; + this.flowingIconResourceLocation = flowingIconResourceLocation; + return this; + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#build() + */ + @Override + public IGT_Fluid build() { + if (stillIconResourceLocation == null) { + withTextureName(fluidName.toLowerCase(Locale.ENGLISH)); + } + return new GT_Fluid(this); + } + + /** + * @inheritDoc from {@link IGT_FluidBuilder#buildAndRegister() + */ + @Override + public IGT_Fluid buildAndRegister() { + if (stillIconResourceLocation == null) { + withTextureName(fluidName.toLowerCase(Locale.ENGLISH)); + } + return build().addFluid(); + } +} |