Skip to content

Commit

Permalink
Add methods to change a material's composition (GregTechCEu#2630)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rundas01 authored Nov 24, 2024
1 parent 0911bbf commit 0160791
Showing 1 changed file with 34 additions and 2 deletions.
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;
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;
}
}
}

0 comments on commit 0160791

Please sign in to comment.