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 +- .../java/gregtech/api/fluid/GT_FluidFactory.java | 80 + .../gregtech/api/interfaces/fluid/IGT_Fluid.java | 71 + .../api/interfaces/fluid/IGT_FluidBuilder.java | 82 + src/main/java/gregtech/api/objects/GT_Fluid.java | 5 + src/main/java/gregtech/common/GT_Proxy.java | 178 +- src/main/java/gregtech/common/fluid/GT_Fluid.java | 207 ++ .../gregtech/common/fluid/GT_FluidBuilder.java | 133 + .../java/gregtech/loaders/load/GT_FuelLoader.java | 18 +- .../preload/GT_Loader_Item_Block_And_Fluid.java | 3019 ++++++++------------ 11 files changed, 1967 insertions(+), 1842 deletions(-) create mode 100644 src/main/java/gregtech/api/enums/FluidState.java create mode 100644 src/main/java/gregtech/api/fluid/GT_FluidFactory.java create mode 100644 src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java create mode 100644 src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java create mode 100644 src/main/java/gregtech/common/fluid/GT_Fluid.java create mode 100644 src/main/java/gregtech/common/fluid/GT_FluidBuilder.java (limited to 'src/main/java/gregtech') 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); } } } diff --git a/src/main/java/gregtech/api/fluid/GT_FluidFactory.java b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java new file mode 100644 index 0000000000..0db1aec7e6 --- /dev/null +++ b/src/main/java/gregtech/api/fluid/GT_FluidFactory.java @@ -0,0 +1,80 @@ +package gregtech.api.fluid; + +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:

+ *
    + *
  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. + *
+ */ +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 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 + * @return the registered {@link IGT_Fluid} + */ + public static IGT_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); + } + + /** + * Helper for quick fluid creation and registration + * @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 + * @return the registered {@link IGT_Fluid} + */ + public static IGT_Fluid of( + final String fluidName, final String localizedName, final FluidState state, final int temperature) { + return builder(fluidName) + .withLocalizedName(localizedName) + .withStateAndTemperature(state, temperature) + .buildAndRegister(); + } + + /** + * 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 + */ + public static IGT_FluidBuilder builder(final String fluidName) { + return new GT_FluidBuilder(fluidName); + } +} diff --git a/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java b/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java new file mode 100644 index 0000000000..1a34b44b5a --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/fluid/IGT_Fluid.java @@ -0,0 +1,71 @@ +package gregtech.api.interfaces.fluid; + +import gregtech.api.enums.FluidState; +import gregtech.api.enums.Materials; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; + +public interface IGT_Fluid { + + /** + * Registers this {@link IGT_Fluid} to ths {@link FluidRegistry} + * + * @return {@link IGT_Fluid} self for call chaining + */ + IGT_Fluid addFluid(); + + /** + * Registers the containers in the {@link FluidContainerRegistry} for this {@link IGT_Fluid} + * + * @param fullContainer The full fluid container + * @param emptyContainer The empty fluid container + * @param containerSize The size of the container + * @return The {@link IGT_Fluid} for chaining + */ + IGT_Fluid registerContainers( + final ItemStack fullContainer, final ItemStack emptyContainer, final int containerSize); + + /** + * Registers the bucket-sized 1000L containers in the {@link FluidContainerRegistry} for this {@link IGT_Fluid} + * + * @param fullContainer The full container to associate with this {@link IGT_Fluid} + * @param emptyContainer The empty container associate with this {@link IGT_Fluid} + * @return {@link IGT_Fluid} self for call chaining + */ + IGT_Fluid registerBContainers(final ItemStack fullContainer, final ItemStack emptyContainer); + + /** + * Registers the potion-sized 250L containers in the {@link FluidContainerRegistry} for this {@link IGT_Fluid} + * + * @param fullContainer The full container to associate with this {@link IGT_Fluid} + * @param emptyContainer The empty container associate with this {@link IGT_Fluid} + * @return {@link IGT_Fluid} self for call chaining + */ + IGT_Fluid registerPContainers(final ItemStack fullContainer, final ItemStack emptyContainer); + + /** + * Updates the {@link Materials}'s fluids from this {@link IGT_Fluid}'s state + * + * @param material the {@link Materials} to configure based on this {@link IGT_Fluid} and {@link FluidState} + * @return The {@link IGT_Fluid} for chaining + */ + IGT_Fluid configureMaterials(final Materials material); + + /** + * @return this {@link IGT_Fluid} cast to {@link Fluid} + */ + Fluid asFluid(); + + /** + * @return the {@link ResourceLocation} of the still fluid texture + */ + ResourceLocation getStillIconResourceLocation(); + + /** + * @return the {@link ResourceLocation} of the flowing fluid texture + */ + ResourceLocation getFlowingIconResourceLocation(); +} diff --git a/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java b/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java new file mode 100644 index 0000000000..1e5ec60fa0 --- /dev/null +++ b/src/main/java/gregtech/api/interfaces/fluid/IGT_FluidBuilder.java @@ -0,0 +1,82 @@ +package gregtech.api.interfaces.fluid; + +import gregtech.api.enums.FluidState; +import net.minecraft.block.Block; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; + +public interface IGT_FluidBuilder { + /** + * @param colorRGBA The {@code short[]} RGBA color of the {@link Fluid} or {@code null} for no defined RGBA color + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withColorRGBA(final short[] colorRGBA); + + /** + * @param localizedName The localized name of this {@link IGT_FluidBuilder} + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withLocalizedName(final String localizedName); + + /** + * @param fluidState The {@link FluidState} of this {@link IGT_FluidBuilder} + * @param temperature The Kelvin temperature of this {@link IGT_FluidBuilder} + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withStateAndTemperature(final FluidState fluidState, final int temperature); + + /** + * @param stillIconResourceLocation the {@link ResourceLocation} of the still fluid icon + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withStillIconResourceLocation(final ResourceLocation stillIconResourceLocation); + + /** + * @param flowingIconResourceLocation the {@link ResourceLocation} of the flowing fluid icon + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withFlowingIconResourceLocation(final ResourceLocation flowingIconResourceLocation); + + /** + * @param textureName The name of the GregTech mod texture of this {@link IGT_FluidBuilder} + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withTextureName(final String textureName); + + /** + * @param fromGTFluid the {@link IGT_Fluid} to copy the texture from + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withTextureFrom(final IGT_Fluid fromGTFluid); + + /** + * @param fluidBlock the {@link Block} implementation of the {@link IGT_Fluid} + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withFluidBlock(final Block fluidBlock); + + /** + * @param stillIconResourceLocation The {@link ResourceLocation} of the still fluid texture + * @param flowingIconResourceLocation The {@link ResourceLocation} of the flowing fluid texture + * @return {@link IGT_FluidBuilder} self for call chaining + */ + IGT_FluidBuilder withTextures( + final ResourceLocation stillIconResourceLocation, final ResourceLocation flowingIconResourceLocation); + + /** + * Builds the {@link IGT_Fluid} + * + * @return the built {@link IGT_Fluid} + */ + IGT_Fluid build(); + + /** + * Builds, then adds the {@link IGT_Fluid} to the {@link FluidRegistry} + * + * @return the {@link IGT_Fluid} + * @see #build() + * @see IGT_Fluid#addFluid() + */ + IGT_Fluid buildAndRegister(); +} diff --git a/src/main/java/gregtech/api/objects/GT_Fluid.java b/src/main/java/gregtech/api/objects/GT_Fluid.java index 52b58d38cc..91c5eac092 100644 --- a/src/main/java/gregtech/api/objects/GT_Fluid.java +++ b/src/main/java/gregtech/api/objects/GT_Fluid.java @@ -3,8 +3,13 @@ package gregtech.api.objects; import static gregtech.api.enums.GT_Values.RES_PATH_BLOCK; import gregtech.api.GregTech_API; +import gregtech.api.fluid.GT_FluidFactory; import net.minecraftforge.fluids.Fluid; +/** + * @deprecated use {@link GT_FluidFactory#builder} + */ +@Deprecated public class GT_Fluid extends Fluid implements Runnable { public final String mTextureName; private final short[] mRGBa; 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(); + } +} diff --git a/src/main/java/gregtech/loaders/load/GT_FuelLoader.java b/src/main/java/gregtech/loaders/load/GT_FuelLoader.java index 463f2fff63..d6d3373248 100644 --- a/src/main/java/gregtech/loaders/load/GT_FuelLoader.java +++ b/src/main/java/gregtech/loaders/load/GT_FuelLoader.java @@ -1,10 +1,12 @@ package gregtech.loaders.load; -import gregtech.GT_Mod; +import static gregtech.api.enums.FluidState.LIQUID; + import gregtech.api.enums.GT_Values; import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; @@ -12,20 +14,20 @@ import gregtech.api.util.GT_Recipe; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.Fluid; public class GT_FuelLoader implements Runnable { @Override public void run() { GT_Log.out.println("GT_Mod: Initializing various Fuels."); ItemList.sBlueVitriol = - GT_Mod.gregtechproxy.addFluid("solution.bluevitriol", "Blue Vitriol water solution", null, 1, 295); + (Fluid) GT_FluidFactory.of("solution.bluevitriol", "Blue Vitriol water solution", LIQUID, 295); ItemList.sNickelSulfate = - GT_Mod.gregtechproxy.addFluid("solution.nickelsulfate", "Nickel sulfate water solution", null, 1, 295); - ItemList.sIndiumConcentrate = GT_Mod.gregtechproxy.addFluid( - "indiumconcentrate", "Indium Concentrate", null, 1, 295); // TODO CHECK NEW x3 - ItemList.sLeadZincSolution = - GT_Mod.gregtechproxy.addFluid("leadzincsolution", "Lead-Zinc solution", null, 1, 295); - ItemList.sRocketFuel = GT_Mod.gregtechproxy.addFluid("rocket_fuel", "Rocket Fuel", null, 1, 295); + (Fluid) GT_FluidFactory.of("solution.nickelsulfate", "Nickel sulfate water solution", LIQUID, 295); + ItemList.sIndiumConcentrate = + (Fluid) GT_FluidFactory.of("indiumconcentrate", "Indium Concentrate", LIQUID, 295); // TODO CHECK NEW x3 + ItemList.sLeadZincSolution = (Fluid) GT_FluidFactory.of("leadzincsolution", "Lead-Zinc solution", LIQUID, 295); + ItemList.sRocketFuel = (Fluid) GT_FluidFactory.of("rocket_fuel", "Rocket Fuel", LIQUID, 295); new GT_Recipe( new ItemStack(Items.lava_bucket), new ItemStack(Blocks.obsidian), diff --git a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java index d39cb75a63..633a8d77ae 100644 --- a/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java +++ b/src/main/java/gregtech/loaders/preload/GT_Loader_Item_Block_And_Fluid.java @@ -1,11 +1,24 @@ package gregtech.loaders.preload; +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.SLURRY; + import codechicken.nei.api.API; import cpw.mods.fml.common.event.FMLInterModComms; import cpw.mods.fml.common.registry.GameRegistry; import gregtech.GT_Mod; import gregtech.api.GregTech_API; -import gregtech.api.enums.*; +import gregtech.api.enums.ConfigCategories; +import gregtech.api.enums.Dyes; +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.MaterialsKevlar; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.enums.SubTag; +import gregtech.api.fluid.GT_FluidFactory; import gregtech.api.items.GT_Block_LongDistancePipe; import gregtech.api.items.GT_BreederCell_Item; import gregtech.api.items.GT_Generic_Item; @@ -16,8 +29,32 @@ import gregtech.api.util.GT_Log; import gregtech.api.util.GT_ModHandler; import gregtech.api.util.GT_OreDictUnificator; import gregtech.api.util.GT_Utility; -import gregtech.common.blocks.*; -import gregtech.common.items.*; +import gregtech.common.blocks.GT_Block_Casings1; +import gregtech.common.blocks.GT_Block_Casings2; +import gregtech.common.blocks.GT_Block_Casings3; +import gregtech.common.blocks.GT_Block_Casings4; +import gregtech.common.blocks.GT_Block_Casings5; +import gregtech.common.blocks.GT_Block_Casings6; +import gregtech.common.blocks.GT_Block_Casings8; +import gregtech.common.blocks.GT_Block_Concretes; +import gregtech.common.blocks.GT_Block_Granites; +import gregtech.common.blocks.GT_Block_Machines; +import gregtech.common.blocks.GT_Block_Metal; +import gregtech.common.blocks.GT_Block_Ores; +import gregtech.common.blocks.GT_Block_Reinforced; +import gregtech.common.blocks.GT_Block_Stones; +import gregtech.common.blocks.GT_TileEntity_Ores; +import gregtech.common.items.GT_DepletetCell_Item; +import gregtech.common.items.GT_FluidDisplayItem; +import gregtech.common.items.GT_IntegratedCircuit_Item; +import gregtech.common.items.GT_MetaGenerated_Item_01; +import gregtech.common.items.GT_MetaGenerated_Item_02; +import gregtech.common.items.GT_MetaGenerated_Item_03; +import gregtech.common.items.GT_MetaGenerated_Item_98; +import gregtech.common.items.GT_MetaGenerated_Item_99; +import gregtech.common.items.GT_MetaGenerated_Tool_01; +import gregtech.common.items.GT_NeutronReflector_Item; +import gregtech.common.items.GT_VolumetricFlask; import java.util.Locale; import net.minecraft.init.Blocks; import net.minecraft.init.Items; @@ -26,7 +63,6 @@ import net.minecraft.item.ItemStack; import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.FluidContainerRegistry; import net.minecraftforge.fluids.FluidRegistry; -import net.minecraftforge.fluids.FluidStack; public class GT_Loader_Item_Block_And_Fluid implements Runnable { @Override @@ -37,44 +73,49 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { GT_Log.out.println("GT_Mod: Register Books."); - GT_Utility.getWrittenBook("Manual_Printer", "Printer Manual V2.0", "Gregorius Techneticies", new String[] { - "This Manual explains the different Functionalities the GregTech Printing Factory has built in, which are not in NEI. Most got NEI Support now, but there is still some left without it.", - "1. Coloring Items and Blocks: You know those Crafting Recipes, which have a dye surrounded by 8 Item to dye them? Or the ones which have just one Item and one Dye in the Grid? Those two Recipe Types can be cheaply automated using the Printer.", - "The Colorization Functionality even optimizes the Recipes, which normally require 8 Items + 1 Dye to 1 Item and an 8th of the normally used Dye in Fluid Form, isn't that awesome?", - "2. Copying Books: This Task got slightly harder. The first Step is putting the written and signed Book inside the Scanner with a Data Stick ready to receive the Data.", - "Now insert the Stick into the Data Slot of the Printer and add 3 pieces of Paper together with 144 Liters of actual Ink Fluid. Water mixed and chemical Dyes won't work on Paper without messing things up!", - "You got a stack of Pages for your new Book, just put them into the Assembler with some Glue and a piece of Leather for the Binding, and you receive an identical copy of the Book, which would stack together with the original.", - "3. Renaming Items: This Functionality is no longer Part of the Printer. There is now a Name Mold for the Forming Press to imprint a Name into an Item, just rename the Mold in an Anvil and use it in the Forming Press on any Item.", - "4. Crafting of Books, Maps, Nametags etc etc etc: Those Recipes moved to other Machines, just look them up in NEI." - }); + GT_Utility.getWrittenBook( + "Manual_Printer", + "Printer Manual V2.0", + "Gregorius Techneticies", + "This Manual explains the different Functionalities the GregTech Printing Factory has built in, which are not in NEI. Most got NEI Support now, but there is still some left without it.", + "1. Coloring Items and Blocks: You know those Crafting Recipes, which have a dye surrounded by 8 Item to dye them? Or the ones which have just one Item and one Dye in the Grid? Those two Recipe Types can be cheaply automated using the Printer.", + "The Colorization Functionality even optimizes the Recipes, which normally require 8 Items + 1 Dye to 1 Item and an 8th of the normally used Dye in Fluid Form, isn't that awesome?", + "2. Copying Books: This Task got slightly harder. The first Step is putting the written and signed Book inside the Scanner with a Data Stick ready to receive the Data.", + "Now insert the Stick into the Data Slot of the Printer and add 3 pieces of Paper together with 144 Liters of actual Ink Fluid. Water mixed and chemical Dyes won't work on Paper without messing things up!", + "You got a stack of Pages for your new Book, just put them into the Assembler with some Glue and a piece of Leather for the Binding, and you receive an identical copy of the Book, which would stack together with the original.", + "3. Renaming Items: This Functionality is no longer Part of the Printer. There is now a Name Mold for the Forming Press to imprint a Name into an Item, just rename the Mold in an Anvil and use it in the Forming Press on any Item.", + "4. Crafting of Books, Maps, Nametags etc etc etc: Those Recipes moved to other Machines, just look them up in NEI."); GT_Utility.getWrittenBook( - "Manual_Punch_Cards", "Punch Card Manual V0.0", "Gregorius Techneticies", new String[] { - "This Manual will explain the Functionality of the Punch Cards, once they are fully implemented. And no, they won't be like the IRL Punch Cards. This is just a current Idea Collection.", - "(i1&&i2)?o1=15:o1=0;=10", - "ignore all Whitespace Characters, use Long for saving the Numbers", - "&& || ^^ & | ^ ! ++ -- + - % / // * ** << >> >>> < > <= >= == != ~ ( ) ?: , ; ;= ;=X; = i0 i1 i2 i3 i4 i5 o0 o1 o2 o3 o4 o5 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 A B C D E F", - "'0' = false, 'everything but 0' = true, '!' turns '0' into '1' and everything else into '0'", - "',' is just a separator for multiple executed Codes in a row.", - "';' means that the Program waits until the next tick before continuing. ';=10' and ';=10;' both mean that it will wait 10 Ticks instead of 1. And ';=0' or anything < 0 will default to 0.", - "If the '=' Operator is used within Brackets, it returns the value the variable has been set to.", - "The Program saves the Char Index of the current Task, the 10 Variables (which reset to 0 as soon as the Program Loop stops), the 10 Member Variables and the remaining waiting Time in its NBT.", - "A = 10, B = 11, C = 12, D = 13, E = 14, F = 15, just for Hexadecimal Space saving, since Redstone has only 4 Bits.", - "For implementing Loops you just need 1 Punch Card per Loop, these Cards can restart once they are finished, depending on how many other Cards there are in the Program Loop you inserted your Card into, since it will process them procedurally.", - "A Punch Card Processor can run up to four Loops, each with the length of seven Punch Cards, parallel.", - "Why does the Punch Card need Ink to be made, you ask? Because the empty one needs to have some lines on, and the for the punched one it prints the Code to execute in a human readable format on the Card." - }); + "Manual_Punch_Cards", + "Punch Card Manual V0.0", + "Gregorius Techneticies", + "This Manual will explain the Functionality of the Punch Cards, once they are fully implemented. And no, they won't be like the IRL Punch Cards. This is just a current Idea Collection.", + "(i1&&i2)?o1=15:o1=0;=10", + "ignore all Whitespace Characters, use Long for saving the Numbers", + "&& || ^^ & | ^ ! ++ -- + - % / // * ** << >> >>> < > <= >= == != ~ ( ) ?: , ; ;= ;=X; = i0 i1 i2 i3 i4 i5 o0 o1 o2 o3 o4 o5 v0 v1 v2 v3 v4 v5 v6 v7 v8 v9 m0 m1 m2 m3 m4 m5 m6 m7 m8 m9 A B C D E F", + "'0' = false, 'everything but 0' = true, '!' turns '0' into '1' and everything else into '0'", + "',' is just a separator for multiple executed Codes in a row.", + "';' means that the Program waits until the next tick before continuing. ';=10' and ';=10;' both mean that it will wait 10 Ticks instead of 1. And ';=0' or anything < 0 will default to 0.", + "If the '=' Operator is used within Brackets, it returns the value the variable has been set to.", + "The Program saves the Char Index of the current Task, the 10 Variables (which reset to 0 as soon as the Program Loop stops), the 10 Member Variables and the remaining waiting Time in its NBT.", + "A = 10, B = 11, C = 12, D = 13, E = 14, F = 15, just for Hexadecimal Space saving, since Redstone has only 4 Bits.", + "For implementing Loops you just need 1 Punch Card per Loop, these Cards can restart once they are finished, depending on how many other Cards there are in the Program Loop you inserted your Card into, since it will process them procedurally.", + "A Punch Card Processor can run up to four Loops, each with the length of seven Punch Cards, parallel.", + "Why does the Punch Card need Ink to be made, you ask? Because the empty one needs to have some lines on, and the for the punched one it prints the Code to execute in a human readable format on the Card."); - GT_Utility.getWrittenBook("Manual_Microwave", "Microwave Oven Manual", "Kitchen Industries", new String[] { - "Congratulations, you inserted a random seemingly empty Book into the Microwave and these Letters appeared out of nowhere.", - "You just got a Microwave Oven and asked yourself 'why do I even need it?'. It's simple, the Microwave can cook for just 128 EU and at an insane speed. Not even a normal E-furnace can do it that fast and cheap!", - "This is the cheapest and fastest way to cook for you. That is why the Microwave Oven can be found in almost every Kitchen (see www.youwannabuyakitchen.ly).", - "Long time exposure to Microwaves can cause Cancer, but we doubt Steve lives long enough to die because of that.", - "Do not insert any Metals. It might result in an Explosion.", - "Do not dry Animals with it. It will result in a Hot Dog, no matter which Animal you put into it.", - "Do not insert inflammable Objects. The Oven will catch on Fire.", - "Do not insert Explosives such as Eggs. Just don't." - }); + GT_Utility.getWrittenBook( + "Manual_Microwave", + "Microwave Oven Manual", + "Kitchen Industries", + "Congratulations, you inserted a random seemingly empty Book into the Microwave and these Letters appeared out of nowhere.", + "You just got a Microwave Oven and asked yourself 'why do I even need it?'. It's simple, the Microwave can cook for just 128 EU and at an insane speed. Not even a normal E-furnace can do it that fast and cheap!", + "This is the cheapest and fastest way to cook for you. That is why the Microwave Oven can be found in almost every Kitchen (see www.youwannabuyakitchen.ly).", + "Long time exposure to Microwaves can cause Cancer, but we doubt Steve lives long enough to die because of that.", + "Do not insert any Metals. It might result in an Explosion.", + "Do not dry Animals with it. It will result in a Hot Dog, no matter which Animal you put into it.", + "Do not insert inflammable Objects. The Oven will catch on Fire.", + "Do not insert Explosives such as Eggs. Just don't."); GT_Log.out.println("GT_Mod: Register Items."); @@ -166,7 +207,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 0.4F, 0, 0.25F, - ItemList.Depleted_Thorium_1.get(1, new Object[0]), + ItemList.Depleted_Thorium_1.get(1), false)); ItemList.ThoriumCell_2.set(new GT_RadioactiveCellIC_Item( "Double_Thoriumcell", @@ -176,7 +217,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 0.4F, 0, 0.25F, - ItemList.Depleted_Thorium_2.get(1, new Object[0]), + ItemList.Depleted_Thorium_2.get(1), false)); ItemList.ThoriumCell_4.set(new GT_RadioactiveCellIC_Item( "Quad_Thoriumcell", @@ -186,27 +227,27 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 0.4F, 0, 0.25F, - ItemList.Depleted_Thorium_4.get(1, new Object[0]), + ItemList.Depleted_Thorium_4.get(1), false)); GT_ModHandler.addThermalCentrifugeRecipe( - ItemList.Depleted_Thorium_1.get(1, new Object[0]), 5000, new Object[] { - GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Lutetium, 2L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 1L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L) - }); + ItemList.Depleted_Thorium_1.get(1), + 5000, + GT_OreDictUnificator.get(OrePrefixes.dustSmall, Materials.Lutetium, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 1L)); GT_ModHandler.addThermalCentrifugeRecipe( - ItemList.Depleted_Thorium_2.get(1, new Object[0]), 5000, new Object[] { - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lutetium, 1L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 2L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 3L) - }); + ItemList.Depleted_Thorium_2.get(1), + 5000, + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lutetium, 1L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 3L)); GT_ModHandler.addThermalCentrifugeRecipe( - ItemList.Depleted_Thorium_4.get(1, new Object[0]), 5000, new Object[] { - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lutetium, 2L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 4L), - GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 6L) - }); + ItemList.Depleted_Thorium_4.get(1), + 5000, + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Lutetium, 2L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Thorium, 4L), + GT_OreDictUnificator.get(OrePrefixes.dust, Materials.Iron, 6L)); ItemList.Depleted_Naquadah_1.set( new GT_DepletetCell_Item("NaquadahcellDep", "Fuel Rod (Depleted Naquadah)", 1)); @@ -222,7 +263,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_Naquadah_1.get(1, new Object[0]), + ItemList.Depleted_Naquadah_1.get(1), false)); ItemList.NaquadahCell_2.set(new GT_RadioactiveCellIC_Item( "Double_Naquadahcell", @@ -232,7 +273,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_Naquadah_2.get(1, new Object[0]), + ItemList.Depleted_Naquadah_2.get(1), false)); ItemList.NaquadahCell_4.set(new GT_RadioactiveCellIC_Item( "Quad_Naquadahcell", @@ -242,7 +283,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_Naquadah_4.get(1, new Object[0]), + ItemList.Depleted_Naquadah_4.get(1), false)); GT_Values.RA.addCentrifugeRecipe( @@ -300,7 +341,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_MNq_1.get(1, new Object[0]), + ItemList.Depleted_MNq_1.get(1), true)); ItemList.MNqCell_2.set(new GT_RadioactiveCellIC_Item( "Double_MNqCell", @@ -310,7 +351,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_MNq_2.get(1, new Object[0]), + ItemList.Depleted_MNq_2.get(1), true)); ItemList.MNqCell_4.set(new GT_RadioactiveCellIC_Item( "Quad_MNqCell", @@ -320,7 +361,7 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { 4F, 1, 1F, - ItemList.Depleted_MNq_4.get(1, new Object[0]), + ItemList.Depleted_MNq_4.get(1), true)); GT_Values.RA.addCentrifugeRecipe( @@ -731,169 +772,141 @@ public class GT_Loader_Item_Block_And_Fluid implements Runnable { .getFluid(); } - GT_Mod.gregtechproxy.addFluid( - "Air", - "Air", - Materials.Air, - 2, - 295, - ItemList.Cell_Air.get(1L, new Object[0]), - ItemList.Cell_Empty.get(1L, new Object[0]), - 2000); - GT_Mod.gregtechproxy.addFluid( - "LiquidOxygen", -