Skip to content

Commit

Permalink
feat: let people set the fluid a material solidifies from
Browse files Browse the repository at this point in the history
  • Loading branch information
bruberu committed Jan 13, 2024
1 parent be65a58 commit 4d13385
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,20 @@
import gregtech.api.fluids.store.FluidStorage;
import gregtech.api.fluids.store.FluidStorageKey;

import gregtech.api.fluids.store.FluidStorageKeys;

import gregtech.api.unification.material.Material;

import net.minecraftforge.fluids.Fluid;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class FluidProperty implements IMaterialProperty {

private final FluidStorage storage = new FluidStorage();
private @Nullable FluidStorageKey primaryKey = null;
private @Nullable Fluid solidifyingFluid = null;

public FluidProperty() {}

Expand All @@ -33,4 +40,15 @@ public void setPrimaryKey(@Nullable FluidStorageKey primaryKey) {

@Override
public void verifyProperty(MaterialProperties properties) {}

public Fluid solidifiesFrom(Material material) {
if (this.solidifyingFluid == null) {
return material.getFluid(FluidStorageKeys.LIQUID);
}
return solidifyingFluid;
}

public void setSolidifyingFluid(@Nullable Fluid solidifyingFluid) {
this.solidifyingFluid = solidifyingFluid;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ public static void processIngot(OrePrefix ingotPrefix, Material material, IngotP
}
}

if (material.hasFluid() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != null) {
RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder()
.notConsumable(MetaItems.SHAPE_MOLD_INGOT)
.fluidInputs(material.getFluid(L))
.fluidInputs(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), L))
.outputs(OreDictUnifier.get(ingotPrefix, material))
.duration(20).EUt(VA[ULV])
.buildAndRegister();
Expand Down Expand Up @@ -425,10 +425,10 @@ public static void processNugget(OrePrefix orePrefix, Material material, DustPro
.output(ingot, material)
.buildAndRegister();

if (material.hasFluid() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != null) {
RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder()
.notConsumable(MetaItems.SHAPE_MOLD_NUGGET)
.fluidInputs(material.getFluid(L))
.fluidInputs(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), L))
.outputs(OreDictUnifier.get(orePrefix, material, 9))
.duration((int) material.getMass())
.EUt(VA[ULV])
Expand Down Expand Up @@ -466,10 +466,10 @@ 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() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != null) {
RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder()
.notConsumable(MetaItems.SHAPE_MOLD_BLOCK)
.fluidInputs(material.getFluid((int) (materialAmount * L / M)))
.fluidInputs(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), ((int) (materialAmount * L / M))))
.outputs(blockStack)
.duration((int) material.getMass()).EUt(VA[ULV])
.buildAndRegister();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

import static gregtech.api.GTValues.*;
import static gregtech.api.recipes.RecipeMaps.BENDER_RECIPES;
Expand Down Expand Up @@ -201,11 +202,11 @@ public static void processGear(OrePrefix gearPrefix, Material material, DustProp
}
}

if (material.hasFluid() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != 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(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), L * (isSmall ? 1 : 4)))
.outputs(stack)
.duration(isSmall ? 20 : 100)
.EUt(VA[ULV])
Expand Down Expand Up @@ -286,10 +287,10 @@ public static void processLens(OrePrefix lensPrefix, Material material, GemPrope
}

public static void processPlate(OrePrefix platePrefix, Material material, DustProperty property) {
if (material.hasFluid() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != null) {
RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder()
.notConsumable(MetaItems.SHAPE_MOLD_PLATE)
.fluidInputs(material.getFluid(L))
.fluidInputs(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), L))
.outputs(OreDictUnifier.get(platePrefix, material))
.duration(40)
.EUt(VA[ULV])
Expand Down Expand Up @@ -400,10 +401,10 @@ public static void processRotor(OrePrefix rotorPrefix, Material material, IngotP
'S', new UnificationEntry(screw, material),
'R', new UnificationEntry(ring, material));

if (material.hasFluid() && material.getFluid(FluidStorageKeys.LIQUID) != null) {
if (material.hasFluid() && material.getProperty(PropertyKey.FLUID).solidifiesFrom(material) != null) {
RecipeMaps.FLUID_SOLIDFICATION_RECIPES.recipeBuilder()
.notConsumable(MetaItems.SHAPE_MOLD_ROTOR)
.fluidInputs(material.getFluid(L * 4))
.fluidInputs(new FluidStack(material.getProperty(PropertyKey.FLUID).solidifiesFrom(material), L * 4))
.outputs(GTUtility.copy(stack))
.duration(120)
.EUt(20)
Expand Down

0 comments on commit 4d13385

Please sign in to comment.