Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve TagPrefix-based Recipe Generation #2616

Open
wants to merge 13 commits into
base: 1.20.1
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class Material implements Comparable<Material> {
* @see MaterialFlags
*/
@NotNull
@Getter
private final MaterialFlags flags;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import com.gregtechceu.gtceu.api.fluids.store.FluidStorage;
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageImpl;
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKey;
import com.gregtechceu.gtceu.api.fluids.store.FluidStorageKeys;
import com.gregtechceu.gtceu.api.registry.registrate.GTRegistrate;

import net.minecraft.world.level.material.Fluid;
import net.minecraftforge.fluids.FluidStack;

import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -25,6 +27,8 @@ public class FluidProperty implements IMaterialProperty, FluidStorage {
@Getter
@Setter
private FluidStorageKey primaryKey = null;
@Setter
private @Nullable Fluid solidifyingFluid = null;

public FluidProperty(@NotNull FluidStorageKey key, @NotNull FluidBuilder builder) {
enqueueRegistration(key, builder);
Expand Down Expand Up @@ -71,6 +75,28 @@ public void store(@NotNull FluidStorageKey key, @NotNull Supplier<? extends Flui
return storage.getQueuedBuilder(key);
}

/**
* @return the Fluid which solidifies into the material.
*/
public @Nullable Fluid solidifiesFrom() {
if (this.solidifyingFluid == null) {
this.solidifyingFluid = 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 @NotNull FluidStack solidifiesFrom(int amount) {
Fluid fluid = solidifiesFrom();
if (fluid == null) {
return FluidStack.EMPTY;
}
return new FluidStack(fluid, amount);
}

@Override
public void verifyProperty(MaterialProperties properties) {
if (this.primaryKey == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class OreProperty implements IMaterialProperty {
Expand Down Expand Up @@ -123,7 +124,31 @@ public void setSeparatedInto(Material... materials) {
this.separatedInto.addAll(Arrays.asList(materials));
}

public void setOreByProducts(Material... materials) {
/**
* Set the ore byproducts for this property
*
* @param materials the materials to use as byproducts
*/
public void setOreByProducts(@NotNull Material @NotNull... materials) {
setOreByProducts(Arrays.asList(materials));
}

/**
* Set the ore byproducts for this property
*
* @param materials the materials to use as byproducts
*/
public void setOreByProducts(@NotNull Collection<Material> materials) {
this.oreByProducts.clear();
this.oreByProducts.addAll(materials);
}

/**
* Add ore byproducts to this property
*
* @param materials the materials to add as byproducts
*/
public void addOreByProducts(@NotNull Material @NotNull... materials) {
this.oreByProducts.addAll(Arrays.asList(materials));
}

Expand Down
Loading