From 0d9aab72aa570f13dc3e32e0d32b3f3a95f95e0a Mon Sep 17 00:00:00 2001 From: Jason Mitchell Date: Mon, 30 Jan 2023 10:56:42 -0800 Subject: [ci skip] spotlessApply with the new settings --- src/main/java/gregtech/api/fluid/FluidTankGT.java | 27 ++++--- .../java/gregtech/api/fluid/GT_FluidFactory.java | 92 +++++++++++----------- 2 files changed, 61 insertions(+), 58 deletions(-) (limited to 'src/main/java/gregtech/api/fluid') 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; /** - *

This class contains helpers factory methods to:

+ *

+ * This class contains helpers factory methods to: + *

*
    - *
  1. - *

    Build {@link IGT_Fluid} instances.

    - *
  2. - *
  3. - *

    Register the corresponding {@link Fluid}, built from an {@link IGT_Fluid}, - * to the {@link FluidRegistry}:

    - *
      - *
    • - *

      Register the optionally associated containers to the {@link FluidContainerRegistry}.

      - *
    • - *
    • - *

      Add the needed Fluid Canner recipes.

      - *
    • - *
    - *
  4. + *
  5. + *

    + * Build {@link IGT_Fluid} instances. + *

    + *
  6. + *
  7. + *

    + * Register the corresponding {@link Fluid}, built from an {@link IGT_Fluid}, to the {@link FluidRegistry}: + *

    + *
      + *
    • + *

      + * Register the optionally associated containers to the {@link FluidContainerRegistry}. + *

      + *
    • + *
    • + *

      + * Add the needed Fluid Canner recipes. + *

      + *
    • + *
    + *
  8. *
*/ @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 */ -- cgit