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

Add methods to change a material's composition #2630

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
36 changes: 34 additions & 2 deletions src/main/java/gregtech/api/unification/material/Material.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@
import gregtech.api.unification.material.info.MaterialFlag;
import gregtech.api.unification.material.info.MaterialFlags;
import gregtech.api.unification.material.info.MaterialIconSet;
import gregtech.api.unification.material.properties.*;
import gregtech.api.unification.material.properties.BlastProperty;
import gregtech.api.unification.material.properties.DustProperty;
import gregtech.api.unification.material.properties.FluidPipeProperties;
import gregtech.api.unification.material.properties.FluidProperty;
import gregtech.api.unification.material.properties.GemProperty;
import gregtech.api.unification.material.properties.IMaterialProperty;
import gregtech.api.unification.material.properties.IngotProperty;
import gregtech.api.unification.material.properties.ItemPipeProperties;
import gregtech.api.unification.material.properties.MaterialProperties;
import gregtech.api.unification.material.properties.OreProperty;
import gregtech.api.unification.material.properties.PolymerProperty;
import gregtech.api.unification.material.properties.PropertyKey;
import gregtech.api.unification.material.properties.RotorProperty;
import gregtech.api.unification.material.properties.ToolProperty;
import gregtech.api.unification.material.properties.WireProperties;
import gregtech.api.unification.material.properties.WoodProperty;
import gregtech.api.unification.material.registry.MaterialRegistry;
import gregtech.api.unification.stack.MaterialStack;
import gregtech.api.util.FluidTooltipUtil;
Expand All @@ -35,7 +50,11 @@
import stanhebben.zenscript.annotations.ZenMethod;
import stanhebben.zenscript.annotations.ZenOperator;

import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;

Expand Down Expand Up @@ -110,6 +129,14 @@ public Material setFormula(String formula, boolean withFormatting) {
return this;
}

@ZenMethod
public Material setComponents(MaterialStack... components) {
this.materialInfo.setComponents(components);
this.chemicalFormula = null;
brachy84 marked this conversation as resolved.
Show resolved Hide resolved
this.chemicalFormula = calculateChemicalFormula();
return this;
}

public ImmutableList<MaterialStack> getMaterialComponents() {
return materialInfo.componentList;
}
Expand Down Expand Up @@ -1172,5 +1199,10 @@ private void verifyInfo(MaterialProperties p, boolean averageRGB) {
}
}
}

public MaterialInfo setComponents(MaterialStack... components) {
this.componentList = ImmutableList.copyOf(Arrays.asList(components));
return this;
}
}
}