Adding Flags
Materials use FlagKeys to handle specific behaviors and whether a TagPrefix should be interacting with that Material.
When adding a flag to a Material, you have two options:
java
// The unit flag() builder method creates the default instance of the FlagKey. This example tells the Ingot TagPrefix that it should be creating an iron ingot.
public static Material Iron = new Material.Builder(Rutile.id("iron"))
.element("iron")
.colour(0xff949496)
.flag(FlagKey.INGOT)
.build();java
// The instanced flag() builder method sets the value of the flag to a specific instance. This example sets the Harvest Tier of the Material to 1 (or stone)
public static Material Iron = new Material.Builder(Rutile.id("iron"))
.element("iron")
.colour(0xff949496)
.flag(FlagKey.HARVEST_TIER, new HarvestTierFlag(1))
.build();Creating Your Own Flag
You can create your own FlagKeys by creating a class that implements IMaterialFlag
Rutile has multiple extensions of IMaterialFlag that can be useful:
StandaloneFlagSimple empty flag. Useful for acting as a boolean.UnitFlag<T>Holds a single typed value that can be retrieved viagetFlagValue(FlagKey<T>)method inMaterial.BiUnitFlag<A, B>Holds two different typed values that can be retrieved viagetFlagValues(FlagKey<T>)method inMaterial.MapFlag<K, V>Holds a typed Map of values that can be retrieved viagetFlagValue(FlagKey<T>, K)method inMaterial.
If you just want to use your Flag for a Prefix, you can just implementIMaterialFlag.
To use your Flag, create a new class and FlagKey using that class.
java
public class MyFlag implements IMaterialFlag {
// You can check the flags of a Material with this to invalidate the Flag if certain conditions are met.
@Override
public void verifyFlag(MaterialFlags flags) {
}
}
public class MyFlagKeys {
public static final FlagKey<MyFlag> MY_FLAG = new FlagKey<>(YourMod.asResource("my_flag"), MyFlag.class);
}Now to add your new Flag to your Material:
java
public static Material Netherium = new Material.Builder(YourMod.asResource("netherium"))
.element("netherium")
.colour(0xff333756)
.flag(MyFlagKeys.MY_FLAG)
.build();Builtin Flags
Rutile has multiple builtin Flags that it uses for its builtin Materials. They are located within FlagKey
FLUID[Instanced] This causes the Material to register a Fluid.VISCOSITY[Instanced] This flag specifies the viscosity of specific Fluids registered under the Material.LUMINOSITY[Instanced] This flag specifies the luminosity (or light emission) of specific Fluids registered under the Material.GEM[Unit] Tells theGemandBlockPrefixes that it should be enabled for the Material. Incompatible withINGOT.INGOT[Unit] Tells theIngotandBlockPrefixes that it should be enabled for the Material. Incompatible withGEM.DUST[Unit] Tells theDustPrefix that it should be enabled for the Material.ORE[UNIT / INSTANCED] Tells theRaw OreandRaw Ore BlockPrefixes that they should be enabled for the Material.HARVEST_TIER[Instanced] Sets the Harvest Tier of the Material, As anint.BURNABLE[Instanced] Sets theburnTimeof the Material, in ticks. Used by MaterialItem to specify the amount of time it lasts as Furnace Fuel with the formula (burnableValue * prefixMaterialAmount / defaultMaterialAmount)DISABLE_RECIPES[Unit] Stops material-specific runtime recipes from being generated for the Material.