aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common
diff options
context:
space:
mode:
authorLéa Gris <lea.gris@noiraude.net>2022-10-01 11:01:53 +0200
committerGitHub <noreply@github.com>2022-10-01 11:01:53 +0200
commit51a41123b0ccdf10cb7b311f8d87d250f78d1b89 (patch)
tree92b545c7768232ee09c89e39281aebff30c470f2 /src/main/java/gregtech/common
parentad7f7b95550d8a27cc5cddc8c419898d8d836713 (diff)
downloadGT5-Unofficial-51a41123b0ccdf10cb7b311f8d87d250f78d1b89.tar.gz
GT5-Unofficial-51a41123b0ccdf10cb7b311f8d87d250f78d1b89.tar.bz2
GT5-Unofficial-51a41123b0ccdf10cb7b311f8d87d250f78d1b89.zip
refactor(fluid_api): fluent interface (#1407)
* refactor(fluid_api): fluent interface Improves the initial construction model into a fluent interface. See: https://java-design-patterns.com/patterns/fluentinterface/ This change provides the built and saved states of a GT_Fluid, with their own interface, so that: object state validations are performed at build time, rather than causing an `IllegalStateException` to be thrown at runtime, with the previous implementation. This also allows the IDE to display and check the applicable methods for the GT_Fluid object's state, as it moves through the call chain. * hotfix off-by-one in FluidState.fromValue * minor: deduplicate buildAndRegister action * fix(withIconsFrom): needs dependency management Cracked fluid Icons were copied too early from non-cracked fluid within the `IGT_FluidBuilder`'s implementation. At this stage, the source Fluid has not registered its own icons yet, so the Cracked fluid got null Icons (fallback to Error checkerboard). This commit delegates the copy of the source fluid's Icons, to the `run` Icons texture's registration task; ensuring the source Fluid runs its own Icons textures registration before copying them, as a light-weight dependency management.
Diffstat (limited to 'src/main/java/gregtech/common')
-rw-r--r--src/main/java/gregtech/common/GT_Proxy.java109
-rw-r--r--src/main/java/gregtech/common/fluid/GT_Fluid.java205
-rw-r--r--src/main/java/gregtech/common/fluid/GT_FluidBuilder.java39
3 files changed, 151 insertions, 202 deletions
diff --git a/src/main/java/gregtech/common/GT_Proxy.java b/src/main/java/gregtech/common/GT_Proxy.java
index 1f0eda5034..3bc5557fac 100644
--- a/src/main/java/gregtech/common/GT_Proxy.java
+++ b/src/main/java/gregtech/common/GT_Proxy.java
@@ -5,6 +5,7 @@ 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;
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;
@@ -43,7 +44,6 @@ 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;
@@ -51,7 +51,6 @@ import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
import gregtech.api.items.GT_MetaGenerated_Item;
import gregtech.api.items.GT_MetaGenerated_Tool;
import gregtech.api.objects.GT_ChunkManager;
-import gregtech.api.objects.GT_Fluid;
import gregtech.api.objects.GT_FluidStack;
import gregtech.api.objects.GT_ItemStack;
import gregtech.api.objects.GT_UO_DimensionList;
@@ -119,6 +118,7 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.MathHelper;
+import net.minecraft.util.ResourceLocation;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.WorldSettings.GameType;
@@ -138,7 +138,6 @@ import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.ChunkDataEvent;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
-import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
@@ -2552,7 +2551,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
} else return;
for (int i = 0; i < 3; i++) {
crackedFluids[i] = GT_FluidFactory.builder(namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH))
- .withTextureFrom((IGT_Fluid) uncrackedFluid)
+ .withIconsFrom(uncrackedFluid)
.withLocalizedName(orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName)
.withColorRGBA(aMaterial.mRGBa)
.withStateAndTemperature(GAS, 775)
@@ -2603,7 +2602,7 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
} else return;
for (int i = 0; i < 3; i++) {
crackedFluids[i] = GT_FluidFactory.builder(namePrefixes[i] + aMaterial.mName.toLowerCase(Locale.ENGLISH))
- .withTextureFrom((IGT_Fluid) uncrackedFluid)
+ .withIconsFrom(uncrackedFluid)
.withLocalizedName(orePrefixes[i].mLocalizedMaterialPre + aMaterial.mDefaultLocalName)
.withColorRGBA(aMaterial.mRGBa)
.withStateAndTemperature(GAS, 775)
@@ -2640,19 +2639,19 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
}
/**
- * @deprecated use {@link IGT_Fluid#addFluid}
+ * @deprecated use {@link GT_FluidFactory#builder}
* @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);
+ return GT_FluidFactory.of(aName, aLocalized, aMaterial, FluidState.VALID_STATES[aState], aTemperatureK);
}
/**
- * @deprecated use {@link IGT_Fluid#addFluid}
- * @see GT_FluidFactory#builder
+ * @deprecated use {@link GT_FluidFactory#builder}
*/
+ @SuppressWarnings({"MethodWithTooManyParameters"}) // Deprecated method
@Deprecated
public Fluid addFluid(
String aName,
@@ -2663,24 +2662,20 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
ItemStack aFullContainer,
ItemStack aEmptyContainer,
int aFluidAmount) {
- return addFluid(
- aName,
- aName.toLowerCase(Locale.ENGLISH),
- aLocalized,
- aMaterial,
- null,
- aState,
- aTemperatureK,
- aFullContainer,
- aEmptyContainer,
- aFluidAmount);
+ return GT_FluidFactory.builder(aName)
+ .withLocalizedName(aLocalized)
+ .withStateAndTemperature(FluidState.fromValue(aState), aTemperatureK)
+ .buildAndRegister()
+ .configureMaterials(aMaterial)
+ .registerContainers(aFullContainer, aEmptyContainer, aFluidAmount)
+ .asFluid();
}
/**
- * @deprecated use {@link IGT_Fluid#addFluid}
- * @see GT_FluidFactory#builder
+ * @deprecated use {@link GT_FluidFactory#builder}
*/
@Deprecated
+ @SuppressWarnings({"MethodWithTooManyParameters"}) // Deprecated method
public Fluid addFluid(
String aName,
String aTexture,
@@ -2692,67 +2687,15 @@ public abstract class GT_Proxy implements IGT_Mod, IGuiHandler, IFuelHandler, IG
ItemStack aFullContainer,
ItemStack aEmptyContainer,
int aFluidAmount) {
- aName = aName.toLowerCase(Locale.ENGLISH);
-
- Fluid rFluid = new GT_Fluid(aName, aTexture, aRGBa != null ? aRGBa : Dyes._NULL.getRGBA());
- GT_LanguageManager.addStringLocalization(rFluid.getUnlocalizedName(), aLocalized == null ? aName : aLocalized);
- if (FluidRegistry.registerFluid(rFluid)) {
- switch (aState) {
- case 0:
- rFluid.setGaseous(false);
- rFluid.setViscosity(10000);
- break;
- case 1:
- case 4:
- rFluid.setGaseous(false);
- rFluid.setViscosity(1000);
- break;
- case 2:
- rFluid.setGaseous(true);
- rFluid.setDensity(-100);
- rFluid.setViscosity(200);
- break;
- case 3:
- rFluid.setGaseous(true);
- rFluid.setDensity(55536);
- rFluid.setViscosity(10);
- rFluid.setLuminosity(15);
- }
- } else {
- rFluid = FluidRegistry.getFluid(aName);
- }
- if (rFluid.getTemperature() == new Fluid("test").getTemperature()) {
- rFluid.setTemperature(aTemperatureK);
- }
- if (aMaterial != null) {
- switch (aState) {
- case 0:
- aMaterial.mSolid = rFluid;
- break;
- case 1:
- aMaterial.mFluid = rFluid;
- break;
- case 2:
- aMaterial.mGas = rFluid;
- break;
- case 3:
- aMaterial.mPlasma = rFluid;
- break;
- case 4:
- aMaterial.mStandardMoltenFluid = rFluid;
- }
- }
- if ((aFullContainer != null)
- && (aEmptyContainer != null)
- && (!FluidContainerRegistry.registerFluidContainer(
- new FluidStack(rFluid, aFluidAmount), aFullContainer, aEmptyContainer))) {
- GT_Values.RA.addFluidCannerRecipe(
- aFullContainer,
- GT_Utility.getContainerItem(aFullContainer, false),
- null,
- new FluidStack(rFluid, aFluidAmount));
- }
- return rFluid;
+ return GT_FluidFactory.builder(aName)
+ .withLocalizedName(aLocalized)
+ .withStillIconResourceLocation(new ResourceLocation(MOD_ID, "fluids/fluid." + aTexture))
+ .withColorRGBA(aRGBa)
+ .withStateAndTemperature(FluidState.fromValue(aState), aTemperatureK)
+ .buildAndRegister()
+ .configureMaterials(aMaterial)
+ .registerContainers(aFullContainer, aEmptyContainer, aFluidAmount)
+ .asFluid();
}
public File getSaveDirectory() {
diff --git a/src/main/java/gregtech/common/fluid/GT_Fluid.java b/src/main/java/gregtech/common/fluid/GT_Fluid.java
index b8bca3116a..e768358503 100644
--- a/src/main/java/gregtech/common/fluid/GT_Fluid.java
+++ b/src/main/java/gregtech/common/fluid/GT_Fluid.java
@@ -5,34 +5,38 @@ 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.interfaces.fluid.IGT_RegisteredFluid;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Utility;
+import javax.annotation.Nonnull;
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 {
+public class GT_Fluid extends Fluid implements IGT_Fluid, IGT_RegisteredFluid, Runnable {
private final String localizedName;
private final ResourceLocation stillIconResourceLocation;
private final ResourceLocation flowingIconResourceLocation;
private final short[] colorRGBA;
private final FluidState fluidState;
+ private final Fluid iconsFrom;
private Fluid registeredFluid;
+ private boolean hasRun = false;
/**
* 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) {
+ protected GT_Fluid(@Nonnull final GT_FluidBuilder builder) {
super(builder.fluidName);
this.localizedName = builder.localizedName;
this.stillIconResourceLocation = builder.stillIconResourceLocation;
this.flowingIconResourceLocation = builder.flowingIconResourceLocation;
+ this.iconsFrom = builder.iconsFrom;
this.block = builder.fluidBlock;
this.colorRGBA = builder.colorRGBA;
this.fluidState = builder.fluidState;
@@ -41,6 +45,37 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
}
/**
+ * Adjusts this {@link Fluid}'s settings based on this {@link IGT_Fluid}'s state
+ */
+ protected void configureFromStateTemperature() {
+ switch (fluidState) {
+ case SLURRY:
+ setGaseous(false).setViscosity(10000);
+ break;
+ case GAS:
+ setGaseous(true).setDensity(-100).setViscosity(200);
+ break;
+ case PLASMA:
+ setGaseous(true).setDensity(55536).setViscosity(10).setLuminosity(15);
+ break;
+ case MOLTEN:
+ final int luminosity;
+ if (temperature >= 3500) {
+ luminosity = 15;
+ } else {
+ luminosity = temperature < 1000 ? 0 : 14 * (temperature - 1000) / 2500 + 1;
+ }
+ setLuminosity(luminosity);
+ case LIQUID:
+ default:
+ setGaseous(false).setViscosity(1000);
+ break;
+ }
+ }
+
+ // ----- Fluid implementations -----
+
+ /**
* @inheritDoc
*/
@Override
@@ -50,61 +85,41 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
| 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.
- *
- * @see 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);
- }
- }
+ // ----- IGT_Fluid interface implementations -----
- /**
- * @inheritDoc
- */
- @Override
- public IGT_Fluid addFluid() {
-
- if (FluidRegistry.registerFluid(this)) {
+ public IGT_RegisteredFluid addFluid() {
+ if (FluidRegistry.registerFluid(GT_Fluid.this)) {
// Registered as a new Fluid
- // Adds self as Runnable to the block icons loader run() tasks
+ registeredFluid = this;
+ // Schedules the gtFluid for the block icons loader run() tasks
GregTech_API.sGTBlockIconload.add(this);
// Adds a server-side localized-name
- GT_LanguageManager.addStringLocalization(this.getUnlocalizedName(), localizedName);
- registeredFluid = this;
+ GT_LanguageManager.addStringLocalization(getUnlocalizedName(), localizedName);
} else {
- // Promotes Fluid from the registry to enable GT_Fluid methods
- registeredFluid = FluidRegistry.getFluid(fluidName);
+ // Fluid already registered, get it from the registry
+ registeredFluid = FluidRegistry.getFluid(GT_Fluid.this.fluidName);
// Sets temperature of already registered fluids if they use the default (temperature = 300)
if (registeredFluid.getTemperature() == new Fluid("test").getTemperature()) {
- registeredFluid.setTemperature(temperature);
+ registeredFluid.setTemperature(GT_Fluid.this.temperature);
}
}
return this;
}
+ // ----- IGT_RegisteredFluid interface implementations -----
+
/**
* @inheritDoc
*/
@Override
- public IGT_Fluid registerContainers(
+ public IGT_RegisteredFluid registerContainers(
final ItemStack fullContainer, final ItemStack emptyContainer, final int containerSize) {
- if (fullContainer == null || emptyContainer == null) return this;
- if (registeredFluid == null) {
- throw new IllegalStateException("Cannot register containers for an unregistered fluid");
- }
- final FluidStack fluidStack = new FluidStack(registeredFluid, containerSize);
- if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) {
- GT_Values.RA.addFluidCannerRecipe(
- fullContainer, GT_Utility.getContainerItem(fullContainer, false), null, fluidStack);
+ if (fullContainer != null && emptyContainer != null) {
+ final FluidStack fluidStack = new FluidStack(registeredFluid, containerSize);
+ if (!FluidContainerRegistry.registerFluidContainer(fluidStack, fullContainer, emptyContainer)) {
+ GT_Values.RA.addFluidCannerRecipe(
+ fullContainer, GT_Utility.getContainerItem(fullContainer, false), null, fluidStack);
+ }
}
return this;
}
@@ -113,7 +128,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
* @inheritDoc
*/
@Override
- public IGT_Fluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) {
+ public IGT_RegisteredFluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer) {
return registerContainers(fullContainer, emptyContainer, 1000);
}
@@ -121,7 +136,7 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
* @inheritDoc
*/
@Override
- public IGT_Fluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) {
+ public IGT_RegisteredFluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer) {
return registerContainers(fullContainer, emptyContainer, 250);
}
@@ -129,45 +144,26 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
* @inheritDoc
*/
@Override
- public ResourceLocation getStillIconResourceLocation() {
- return stillIconResourceLocation;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public ResourceLocation getFlowingIconResourceLocation() {
- return flowingIconResourceLocation;
- }
-
- /**
- * @inheritDoc
- */
- @Override
- public IGT_Fluid configureMaterials(final Materials material) {
- if (registeredFluid == null) {
- throw new IllegalStateException("Cannot configure Materials with an unregistered fluid");
- }
-
- switch (fluidState) {
- case SLURRY:
- material.mSolid = registeredFluid;
- break;
- case LIQUID:
- material.mFluid = registeredFluid;
- break;
- case GAS:
- material.mGas = registeredFluid;
- break;
- case PLASMA:
- material.mPlasma = registeredFluid;
- break;
- case MOLTEN:
- material.mStandardMoltenFluid = registeredFluid;
- break;
- default:
- throw new IllegalStateException("Unexpected FluidState: " + fluidState);
+ public IGT_RegisteredFluid configureMaterials(final Materials material) {
+ if (material != null) {
+ switch (fluidState) {
+ case SLURRY:
+ material.mSolid = registeredFluid;
+ break;
+ case GAS:
+ material.mGas = registeredFluid;
+ break;
+ case PLASMA:
+ material.mPlasma = registeredFluid;
+ break;
+ case MOLTEN:
+ material.mStandardMoltenFluid = registeredFluid;
+ break;
+ case LIQUID:
+ default:
+ material.mFluid = registeredFluid;
+ break;
+ }
}
return this;
}
@@ -177,33 +173,34 @@ public class GT_Fluid extends Fluid implements IGT_Fluid, Runnable {
*/
@Override
public Fluid asFluid() {
- return registeredFluid == null ? this : registeredFluid;
+ return registeredFluid;
}
+ // ----- Runnable interface implementations -----
+
/**
- * Adjusts this {@link Fluid}'s settings based on this {@link IGT_Fluid}'s state
+ * This {@link Runnable#run()} implementation is scheduled within the {@link GregTech_API#sGTBlockIconload}
+ * to load this {@link IGT_Fluid}'s texture icons.
*
- * @throws IllegalStateException if {@link FluidState} is unknown
+ * @see Runnable#run()
*/
- protected void configureFromStateTemperature() {
- switch (fluidState) {
- case SLURRY:
- setGaseous(false).setViscosity(10000);
- break;
- case LIQUID:
- case MOLTEN:
- final int luminosity =
- temperature >= 3500 ? 15 : temperature < 1000 ? 0 : 14 * (temperature - 1000) / 2500 + 1;
- setGaseous(false).setViscosity(1000).setLuminosity(luminosity);
- break;
- case GAS:
- setGaseous(true).setDensity(-100).setViscosity(200);
- break;
- case PLASMA:
- setGaseous(true).setDensity(55536).setViscosity(10).setLuminosity(15);
- break;
- default:
- throw new IllegalStateException("Unexpected FluidState: " + fluidState);
+ @Override
+ public void run() {
+ if (!hasRun) {
+ if (iconsFrom instanceof GT_Fluid) {
+ // Needs the GT_Fluid to have registered its icons
+ ((GT_Fluid) iconsFrom).run();
+ stillIcon = iconsFrom.getStillIcon();
+ flowingIcon = iconsFrom.getFlowingIcon();
+ } else {
+ if (stillIconResourceLocation != null) {
+ stillIcon = GregTech_API.sBlockIcons.registerIcon(stillIconResourceLocation.toString());
+ }
+ if (flowingIconResourceLocation != null) {
+ flowingIcon = GregTech_API.sBlockIcons.registerIcon(flowingIconResourceLocation.toString());
+ }
+ }
+ hasRun = true;
}
}
}
diff --git a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java
index b484f7aacb..48d4e0e95e 100644
--- a/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java
+++ b/src/main/java/gregtech/common/fluid/GT_FluidBuilder.java
@@ -6,21 +6,28 @@ 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 gregtech.api.interfaces.fluid.IGT_RegisteredFluid;
import java.util.Locale;
+import javax.annotation.Nonnull;
import net.minecraft.block.Block;
+import net.minecraft.util.IIcon;
import net.minecraft.util.ResourceLocation;
+import net.minecraftforge.fluids.Fluid;
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;
+ final String fluidName;
+ String localizedName;
+ ResourceLocation stillIconResourceLocation = null, flowingIconResourceLocation = null;
+ short[] colorRGBA = Dyes._NULL.getRGBA();
+ Block fluidBlock = null;
+ FluidState fluidState;
+ int temperature;
+ IIcon stillIcon;
+ IIcon flowingIcon;
+ Fluid iconsFrom;
public GT_FluidBuilder(final String fluidName) {
- this.fluidName = fluidName;
+ this.fluidName = fluidName.toLowerCase(Locale.ENGLISH);
}
/**
@@ -83,9 +90,8 @@ public class GT_FluidBuilder implements IGT_FluidBuilder {
* @inheritDoc
*/
@Override
- public IGT_FluidBuilder withTextureFrom(final IGT_Fluid fromGTFluid) {
- this.stillIconResourceLocation = fromGTFluid.getStillIconResourceLocation();
- this.flowingIconResourceLocation = fromGTFluid.getFlowingIconResourceLocation();
+ public IGT_FluidBuilder withIconsFrom(@Nonnull final Fluid fromFluid) {
+ this.iconsFrom = fromFluid;
return this;
}
@@ -114,9 +120,15 @@ public class GT_FluidBuilder implements IGT_FluidBuilder {
*/
@Override
public IGT_Fluid build() {
+ if (colorRGBA == null) {
+ colorRGBA = Dyes._NULL.getRGBA();
+ }
if (stillIconResourceLocation == null) {
withTextureName(fluidName.toLowerCase(Locale.ENGLISH));
}
+ if (localizedName == null) {
+ localizedName = fluidName;
+ }
return new GT_Fluid(this);
}
@@ -124,10 +136,7 @@ public class GT_FluidBuilder implements IGT_FluidBuilder {
* @inheritDoc
*/
@Override
- public IGT_Fluid buildAndRegister() {
- if (stillIconResourceLocation == null) {
- withTextureName(fluidName.toLowerCase(Locale.ENGLISH));
- }
+ public IGT_RegisteredFluid buildAndRegister() {
return build().addFluid();
}
}