diff --git a/src/main/java/gregtech/api/enums/material/FluidMaterial.java b/src/main/java/gregtech/api/enums/material/FluidMaterial.java index 8de9f20d..7cd8968f 100644 --- a/src/main/java/gregtech/api/enums/material/FluidMaterial.java +++ b/src/main/java/gregtech/api/enums/material/FluidMaterial.java @@ -4,6 +4,23 @@ import net.minecraftforge.fluids.FluidStack; public interface FluidMaterial { + final class MatFlags { + + /** + * Add to fluid material to have it's cell generated + */ + public static final int GENERATE_CELL = Material.MatFlags.createFlag(3); + + /** + * Add to fluid material to have plasma fluid generated + */ + public static final int GENERATE_PLASMA = Material.MatFlags.createFlag(4); + + + + } + + default boolean hasFluid() { return getFluid(1) != null; } diff --git a/src/main/java/gregtech/api/enums/material/builder/DustMaterialBuilder.java b/src/main/java/gregtech/api/enums/material/builder/DustMaterialBuilder.java index f6fc9856..e0591881 100644 --- a/src/main/java/gregtech/api/enums/material/builder/DustMaterialBuilder.java +++ b/src/main/java/gregtech/api/enums/material/builder/DustMaterialBuilder.java @@ -156,24 +156,18 @@ public class DustMaterialBuilder materialStacks1 = ImmutableList.copyOf(materialCompounds); - ImmutableList subTags1 = ImmutableList.copyOf(subTags); - ImmutableList reRegistrations = ImmutableList.of(); - ImmutableList byProducts = ImmutableList.copyOf(oreByProducts); - return (T) new DustMaterial( defaultLocalizedName, rgbColor, iconSet, - materialStacks1, - reRegistrations, - subTags1, + ImmutableList.copyOf(materialCompounds), + ImmutableList.copyOf(oreReRegistrations), + ImmutableList.copyOf(subTags), materialGenerationBits, densityMultiplier, directElement, oreValue, - byProducts, + ImmutableList.copyOf(oreByProducts), oreMultiplier, byProductMultiplier, smeltingMultiplier, diff --git a/src/main/java/gregtech/api/enums/material/builder/FluidMaterialBuilder.java b/src/main/java/gregtech/api/enums/material/builder/FluidMaterialBuilder.java new file mode 100644 index 00000000..0b132b50 --- /dev/null +++ b/src/main/java/gregtech/api/enums/material/builder/FluidMaterialBuilder.java @@ -0,0 +1,27 @@ +package gregtech.api.enums.material.builder; + +import com.google.common.collect.ImmutableList; +import gregtech.api.enums.material.types.FluidMaterialType; + +public class FluidMaterialBuilder> extends MaterialBuilder implements IFluidMaterialBuilder { + + public FluidMaterialBuilder(String name, String defaultLocalizedName) { + super(name, defaultLocalizedName); + } + + @Override + protected T build() { + return (T) new FluidMaterialType( + defaultLocalizedName, + rgbColor, + iconSet, + ImmutableList.copyOf(materialCompounds), + ImmutableList.copyOf(oreReRegistrations), + ImmutableList.copyOf(subTags), + materialGenerationBits, + densityMultiplier, + directElement + ); + } + +} diff --git a/src/main/java/gregtech/api/enums/material/builder/IFluidMaterialBuilder.java b/src/main/java/gregtech/api/enums/material/builder/IFluidMaterialBuilder.java new file mode 100644 index 00000000..4a18113a --- /dev/null +++ b/src/main/java/gregtech/api/enums/material/builder/IFluidMaterialBuilder.java @@ -0,0 +1,26 @@ +package gregtech.api.enums.material.builder; + +import gregtech.api.enums.material.FluidMaterial; +import gregtech.api.enums.material.Material; + +//should be T extends FluidMaterial, but it is interface +public interface IFluidMaterialBuilder> { + + /** + * Enables a cell meta-item generation for this material + */ + default Self enableCell() { + ((Self) this).materialGenerationBits |= FluidMaterial.MatFlags.GENERATE_CELL; + return (Self) this; + } + + /** + * Enables plasma fluid generation for this material + * + */ + default Self enablePlasma() { + ((Self) this).materialGenerationBits |= FluidMaterial.MatFlags.GENERATE_PLASMA; + return (Self) this; + } + +} diff --git a/src/main/java/gregtech/api/enums/material/builder/MaterialBuilder.java b/src/main/java/gregtech/api/enums/material/builder/MaterialBuilder.java index 3d860e08..ba9d529a 100644 --- a/src/main/java/gregtech/api/enums/material/builder/MaterialBuilder.java +++ b/src/main/java/gregtech/api/enums/material/builder/MaterialBuilder.java @@ -6,6 +6,7 @@ import gregtech.api.enums.Element; import gregtech.api.enums.SubTag; import gregtech.api.enums.material.Material; import gregtech.api.enums.material.MaterialIconSet; +import gregtech.api.enums.material.types.MarkerMaterial; import gregtech.api.objects.MaterialStack; import java.util.ArrayList; @@ -21,6 +22,7 @@ public abstract class MaterialBuilder materialCompounds = new ArrayList<>(); + protected ArrayList oreReRegistrations = new ArrayList<>(); protected int metaItemSubId = -1; public MaterialBuilder(String name, String defaultLocalizedName) { @@ -28,45 +30,96 @@ public abstract class MaterialBuilder 0, "Cannot add empty compounds array!"); @@ -109,13 +193,23 @@ public abstract class MaterialBuilder 0) { Material.MATERIAL_REGISTRY.register(metaItemSubId, name, material); } else Material.MATERIAL_REGISTRY.putObject(name, material); + return material; } } diff --git a/src/main/java/gregtech/api/enums/material/types/FluidMaterialType.java b/src/main/java/gregtech/api/enums/material/types/FluidMaterialType.java index f8678edf..849857a0 100644 --- a/src/main/java/gregtech/api/enums/material/types/FluidMaterialType.java +++ b/src/main/java/gregtech/api/enums/material/types/FluidMaterialType.java @@ -1,6 +1,7 @@ package gregtech.api.enums.material.types; import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; import gregtech.api.enums.Element; import gregtech.api.enums.SubTag; import gregtech.api.enums.material.Material; @@ -16,7 +17,7 @@ public class FluidMaterialType extends Material implements gregtech.api.enums.ma private Fluid materialFluid; private Fluid materialPlasma; - public FluidMaterialType(String defaultLocalName, int materialRGB, MaterialIconSet materialIconSet, List materialComponents, List oreReRegistrations, List subTags, int materialGenerationFlags, float densityMultiplier, Element element) { + public FluidMaterialType(String defaultLocalName, int materialRGB, MaterialIconSet materialIconSet, ImmutableList materialComponents, ImmutableList oreReRegistrations, ImmutableList subTags, int materialGenerationFlags, float densityMultiplier, Element element) { super(defaultLocalName, materialRGB, materialIconSet, materialComponents, oreReRegistrations, subTags, materialGenerationFlags, densityMultiplier, element); } diff --git a/src/main/java/gregtech/api/enums/material/types/MarkerMaterial.java b/src/main/java/gregtech/api/enums/material/types/MarkerMaterial.java new file mode 100644 index 00000000..24592fce --- /dev/null +++ b/src/main/java/gregtech/api/enums/material/types/MarkerMaterial.java @@ -0,0 +1,28 @@ +package gregtech.api.enums.material.types; + +import com.google.common.collect.ImmutableList; +import gregtech.api.enums.SubTag; +import gregtech.api.enums.material.Material; +import gregtech.api.enums.material.MaterialIconSet; +import gregtech.api.objects.MaterialStack; + +/** + * MarkerMaterial is type of material used for generic things like material re-registration and use in recipes + * Marker material cannot be used to generate any meta items + * Marker material can be used only for marking other materials (re-registeoring) equal to it and then using it in recipes or in getting items v + */ +public final class MarkerMaterial extends Material { + + public MarkerMaterial(String defaultLocalName, int materialRGB) { + super(defaultLocalName, + materialRGB, + MaterialIconSet.NONE, + ImmutableList.of(), + ImmutableList.of(), + ImmutableList.of(), + 0, + 1.0f, + null); + } + +}