From f294ce818826a317fc53709b84fb5355e061c4be Mon Sep 17 00:00:00 2001 From: Tom Prince Date: Thu, 19 Dec 2024 16:52:42 -0800 Subject: [PATCH] Allow specifying tag prefixes to ignore in material builder. --- .../api/data/chemical/material/Material.java | 16 ++++++++++++++++ .../gtceu/common/data/GTMaterials.java | 3 --- .../materials/UnknownCompositionMaterials.java | 2 ++ 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java index 7c03e2c974..e175c9a93e 100644 --- a/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java +++ b/src/main/java/com/gregtechceu/gtceu/api/data/chemical/material/Material.java @@ -8,6 +8,7 @@ import com.gregtechceu.gtceu.api.data.chemical.material.properties.*; import com.gregtechceu.gtceu.api.data.chemical.material.stack.MaterialStack; import com.gregtechceu.gtceu.api.data.medicalcondition.MedicalCondition; +import com.gregtechceu.gtceu.api.data.tag.TagPrefix; import com.gregtechceu.gtceu.api.data.tag.TagUtil; import com.gregtechceu.gtceu.api.fluids.FluidBuilder; import com.gregtechceu.gtceu.api.fluids.FluidState; @@ -531,6 +532,7 @@ public static class Builder extends BuilderBase { private final MaterialInfo materialInfo; private final MaterialProperties properties; private final MaterialFlags flags; + private Set ignoredTagPrefixes = null; /* * The temporary list of components for this Material. @@ -1010,6 +1012,17 @@ public Builder appendFlags(Collection f1, MaterialFlag... f2) { return this; } + /** + * Add {@link TagPrefixes} to be ignored by this Material.
+ */ + public Builder ignoredTagPrefixes(TagPrefix... prefixes) { + if (this.ignoredTagPrefixes == null) { + this.ignoredTagPrefixes = new HashSet<>(); + } + this.ignoredTagPrefixes.addAll(Arrays.asList(prefixes)); + return this; + } + public Builder element(Element element) { this.materialInfo.element = element; return this; @@ -1239,6 +1252,9 @@ public Material buildAndRegister() { var mat = new Material(materialInfo, properties, flags); materialInfo.verifyInfo(properties, averageRGB); mat.registerMaterial(); + if (ignoredTagPrefixes != null) { + ignoredTagPrefixes.forEach(p -> p.setIgnored(mat)); + } return mat; } diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterials.java index b6ff2a27c3..025b71cd24 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/GTMaterials.java @@ -225,9 +225,6 @@ public static void init() { plate.setIgnored(BorosilicateGlass); foil.setIgnored(BorosilicateGlass); - dustSmall.setIgnored(Lapotron); - dustTiny.setIgnored(Lapotron); - dye.setIgnored(DyeBlack, Items.BLACK_DYE); dye.setIgnored(DyeRed, Items.RED_DYE); dye.setIgnored(DyeGreen, Items.GREEN_DYE); diff --git a/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java b/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java index 4ebd2b5908..c132e689f7 100644 --- a/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java +++ b/src/main/java/com/gregtechceu/gtceu/common/data/materials/UnknownCompositionMaterials.java @@ -11,6 +11,7 @@ import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialFlags.*; import static com.gregtechceu.gtceu.api.data.chemical.material.info.MaterialIconSet.*; +import static com.gregtechceu.gtceu.api.data.tag.TagPrefix.*; import static com.gregtechceu.gtceu.common.data.GTMaterials.*; public class UnknownCompositionMaterials { @@ -542,6 +543,7 @@ public static void register() { .gem() .color(0x7497ea).secondaryColor(0x1c0b39).iconSet(DIAMOND) .flags(NO_UNIFICATION) + .ignoredTagPrefixes(dustTiny, dustSmall) .buildAndRegister(); TreatedWood = new Material.Builder(GTCEu.id("treated_wood"))