diff --git a/src/main/java/gregtech/api/unification/material/properties/FluidProperty.java b/src/main/java/gregtech/api/unification/material/properties/FluidProperty.java index 48f92084252..80c971fb4f1 100644 --- a/src/main/java/gregtech/api/unification/material/properties/FluidProperty.java +++ b/src/main/java/gregtech/api/unification/material/properties/FluidProperty.java @@ -2,6 +2,10 @@ import gregtech.api.fluids.store.FluidStorage; import gregtech.api.fluids.store.FluidStorageKey; +import gregtech.api.fluids.store.FluidStorageKeys; + +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -10,6 +14,7 @@ public class FluidProperty implements IMaterialProperty { private final FluidStorage storage = new FluidStorage(); private @Nullable FluidStorageKey primaryKey = null; + private @Nullable Fluid solidifyingFluid = null; public FluidProperty() {} @@ -33,4 +38,33 @@ public void setPrimaryKey(@Nullable FluidStorageKey primaryKey) { @Override public void verifyProperty(MaterialProperties properties) {} + + /** + * @return the Fluid which solidifies into the material. + */ + + public Fluid solidifiesFrom() { + if (this.solidifyingFluid == null) { + return getStorage().get(FluidStorageKeys.LIQUID); + } + return solidifyingFluid; + } + + /** + * @param amount the size of the returned FluidStack. + * @return a FluidStack of the Fluid which solidifies into the material. + */ + public FluidStack solidifiesFrom(int amount) { + return new FluidStack(solidifiesFrom(), amount); + } + + /** + * Sets the fluid that solidifies into the material. + * + * @param solidifyingFluid The Fluid which solidifies into the material. If left null, it will be left as the + * default value: the material's liquid. + */ + public void setSolidifyingFluid(@Nullable Fluid solidifyingFluid) { + this.solidifyingFluid = solidifyingFluid; + } } diff --git a/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java index ac915b45dc7..74239ff12ae 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/MaterialRecipeHandler.java @@ -286,10 +286,10 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP } } - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_INGOT) - .fluidInputs(material.getFluid(L)) + .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(ingotPrefix, material)) .duration(20).EUt(VA[ULV]) .buildAndRegister(); @@ -424,10 +424,10 @@ public static void processNugget(OrePrefix orePrefix, Material material, DustPro .output(ingot, material) .buildAndRegister(); - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_NUGGET) - .fluidInputs(material.getFluid(L)) + .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(orePrefix, material, 9)) .duration((int) material.getMass()) .EUt(VA[ULV]) @@ -465,10 +465,11 @@ public static void processFrame(OrePrefix framePrefix, Material material, DustPr public static void processBlock(OrePrefix blockPrefix, Material material, DustProperty property) { ItemStack blockStack = OreDictUnifier.get(blockPrefix, material); long materialAmount = blockPrefix.getMaterialAmount(material); - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_BLOCK) - .fluidInputs(material.getFluid((int) (materialAmount * L / M))) + .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom( + ((int) (materialAmount * L / M)))) .outputs(blockStack) .duration((int) material.getMass()).EUt(VA[ULV]) .buildAndRegister(); diff --git a/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java b/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java index 24ec5349133..ddff63fd34a 100644 --- a/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java +++ b/src/main/java/gregtech/loaders/recipe/handlers/PartsRecipeHandler.java @@ -200,11 +200,12 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp } } - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { boolean isSmall = gearPrefix == OrePrefix.gearSmall; RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(isSmall ? MetaItems.SHAPE_MOLD_GEAR_SMALL : MetaItems.SHAPE_MOLD_GEAR) - .fluidInputs(material.getFluid(L * (isSmall ? 1 : 4))) + .fluidInputs( + material.getProperty(PropertyKey.FLUID).solidifiesFrom(L * (isSmall ? 1 : 4))) .outputs(stack) .duration(isSmall ? 20 : 100) .EUt(VA[ULV]) @@ -285,10 +286,10 @@ public static void processLens(OrePrefix lensPrefix, Material material, GemPrope } public static void processPlate(OrePrefix platePrefix, Material material, DustProperty property) { - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_PLATE) - .fluidInputs(material.getFluid(L)) + .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L)) .outputs(OreDictUnifier.get(platePrefix, material)) .duration(40) .EUt(VA[ULV]) @@ -399,10 +400,10 @@ public static void processRotor(OrePrefix rotorPrefix, Material material, IngotP 'S', new UnificationEntry(screw, material), 'R', new UnificationEntry(ring, material)); - if (material.hasFluid()) { + if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom() != null) { RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder() .notConsumable(MetaItems.SHAPE_MOLD_ROTOR) - .fluidInputs(material.getFluid(L * 4)) + .fluidInputs(material.getProperty(PropertyKey.FLUID).solidifiesFrom(L * 4)) .outputs(GTUtility.copy(stack)) .duration(120) .EUt(20)