aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/api/fluid
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/api/fluid')
-rw-r--r--src/main/java/gregtech/api/fluid/FluidTankGT.java27
-rw-r--r--src/main/java/gregtech/api/fluid/GT_FluidFactory.java92
2 files changed, 61 insertions, 58 deletions
diff --git a/src/main/java/gregtech/api/fluid/FluidTankGT.java b/src/main/java/gregtech/api/fluid/FluidTankGT.java
index 93b3c87575..f10e65d100 100644
--- a/src/main/java/gregtech/api/fluid/FluidTankGT.java
+++ b/src/main/java/gregtech/api/fluid/FluidTankGT.java
@@ -2,16 +2,19 @@ package gregtech.api.fluid;
import static com.google.common.primitives.Ints.saturatedCast;
-import gregtech.api.util.GT_Utility;
import java.util.Map;
+
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidTank;
+import gregtech.api.util.GT_Utility;
+
public class FluidTankGT implements IFluidTank {
- public final FluidTankGT[] AS_ARRAY = new FluidTankGT[] {this};
+
+ public final FluidTankGT[] AS_ARRAY = new FluidTankGT[] { this };
private FluidStack mFluid;
private long mCapacity = 0, mAmount = 0;
private boolean mPreventDraining = false, mVoidExcess = false, mChangedFluids = false;
@@ -191,18 +194,15 @@ public class FluidTankGT implements IFluidTank {
return mVoidExcess ? aFluid.amount : (int) tFilled;
}
return saturatedCast(
- isEmpty()
- ? mVoidExcess ? aFluid.amount : Math.min(capacity(aFluid), aFluid.amount)
+ isEmpty() ? mVoidExcess ? aFluid.amount : Math.min(capacity(aFluid), aFluid.amount)
: contains(aFluid)
? mVoidExcess ? aFluid.amount : Math.min(capacity(aFluid) - mAmount, aFluid.amount)
: 0);
}
public boolean canFillAll(FluidStack aFluid) {
- return aFluid == null
- || aFluid.amount <= 0
- || (isEmpty()
- ? mVoidExcess || aFluid.amount <= capacity(aFluid)
+ return aFluid == null || aFluid.amount <= 0
+ || (isEmpty() ? mVoidExcess || aFluid.amount <= capacity(aFluid)
: contains(aFluid) && (mVoidExcess || mAmount + aFluid.amount <= capacity(aFluid)));
}
@@ -263,6 +263,7 @@ public class FluidTankGT implements IFluidTank {
}
return false;
}
+
/** Resets Tank Contents entirely */
public FluidTankGT setEmpty() {
mFluid = null;
@@ -271,7 +272,7 @@ public class FluidTankGT implements IFluidTank {
return this;
}
- /** Sets Fluid Content, taking Amount from the Fluid Parameter */
+ /** Sets Fluid Content, taking Amount from the Fluid Parameter */
public FluidTankGT setFluid(FluidStack aFluid) {
mFluid = aFluid;
mChangedFluids = true;
@@ -287,7 +288,7 @@ public class FluidTankGT implements IFluidTank {
return this;
}
- /** Sets Fluid Content, taking Amount from the Tank Parameter */
+ /** Sets Fluid Content, taking Amount from the Tank Parameter */
public FluidTankGT setFluid(FluidTankGT aTank) {
mFluid = new FluidStack(aTank.mFluid, saturatedCast(aTank.mAmount));
mChangedFluids = true;
@@ -306,7 +307,8 @@ public class FluidTankGT implements IFluidTank {
if (aCapacity >= 0) mCapacity = aCapacity;
return this;
}
- /** Sets the Capacity Multiplier */
+
+ /** Sets the Capacity Multiplier */
public FluidTankGT setCapacityMultiplier(long aCapacityMultiplier) {
if (aCapacityMultiplier >= 0) mAdjustableMultiplier = aCapacityMultiplier;
return this;
@@ -363,8 +365,7 @@ public class FluidTankGT implements IFluidTank {
if (mAdjustableCapacity == null || aFluid == null) return mCapacity;
final Long tSize = mAdjustableCapacity.get(aFluid);
- return tSize == null
- ? Math.max(mAmount, mCapacity)
+ return tSize == null ? Math.max(mAmount, mCapacity)
: Math.max(tSize * mAdjustableMultiplier, Math.max(mAmount, mCapacity));
}
diff --git a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java
index 1622aa2e05..b392167147 100644
--- a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java
+++ b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java
@@ -1,32 +1,42 @@
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.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>
+ * <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>
+ * <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
@@ -34,46 +44,38 @@ 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 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
+ * @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();
+ 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 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
+ * @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();
+ 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
*/