Skip to content

Creating Prefixes

The TagPrefix is a registered object that act as the backbone of any Material. They register Blocks and Items.
You do not need to register your Prefixes yourself as they are registered upon the creation of a new instance.

Since they are registered objects, unlike FlagKeys, they use a ResourceLocation.

Creating a new instance.

java
// Create a class to hold your prefixes
public class MyTagPrefixes {

    // Creates and registers a Prefix that generates a "dust" item if the Material has the DUST flag.
    public static TagPrefix Dust = new TagPrefix(YourMod.asResource("dust"))
            .defaultTagPath("dusts/%s")
            .unformattedTagPath("dusts")
            .materialAmount(TagPrefix.M)
            .unificationEnabled(true)
            .generateItem(true)
            .generationCondition(hasFlag(MyFlagKeys.DUST));

    public static void init() {}
}
//Call init during the RegisterEvent to ensure the registration of your prefixes

@SubscribeEvent
public static void onRegister(RegisterEvent event) {
    if (didRunRegistration) {
        return;
    }
    MyElements.init();
    MyMaterials.init();
    // Initialize your Prefixes:
    MyTagPrefixes.init();
    didRunRegistration = true;
}

TagPrefix Builder Methods


When creating your TagPrefix, there are many different builder methods you can use to make it behave differently...
  • defaultTagPath(String path) Sets the path that the Material-specific tag should be located at. The value of path should contain "%s" as it will be formatted to the material name. Eg: "ingots/%s".
  • prefixTagPath(String path) Sets the path that the Prefix AND Material specific tag should be located at. The value of path should contain two instances of "%s" as it will be formatted with the prefix name and the material name. Eg: "%s/%s".
  • unformattedTagPath(String path) Sets the path that the group tag should be located at. No formatting is needed for the path as this tag is used to group together all the tags in the defaultTagPath location. Eg: "ingots"
  • customTagPath(String path, BiFunction<TagPrefix, Material, TagKey<Item>> formatter) Sets the path that the Material-specific tag should be located at. You can use this to specify the formatting rules for the tag path and, as such, you can decide how many instances of "%s" you need.
  • miningToolTag(TagKey<Block> tag) Sets the mineable tag for block prefixes. Eg: BlockTags.MINEABLE_WITH_PICKAXE.
  • blockProperties(Supplier<Supplier<RenderType>> renderType, UnaryOperator<BlockBehaviour.Properties> properties) Sets the default properties and renderType of the Block generated by the Prefix. Eg: (() -> RenderType::translucent, (properties -> properties.friction(0.5f)))
  • langValue(String value) Sets the English unformatted language value for the prefix. Eg: "Block of %s".
  • materialAmount(long amount) Sets the amount of material the registered object would hold. Eg: TagPrefix.M * 9.
  • generateItem(boolean bool) Whether or not the prefix should be registering an Item.
  • generateBlock(boolean bool) Whether or not the prefix should be registering a Block.
  • itemConstructor(ItemConstructor constructor) The constructor for the generated Item. Eg: MaterialItem::new.
  • blockConstructor(BlockConstructor constructor) The constructor for the generated Block. Eg: MaterialBlock::new.
  • blockItemConstructor(BlockItemConstructor constructor) The constructor for the generated Block Item. Eg: MaterialBlockItem::new.
  • blockAssetProperties(BlockAssetProperties props) Sets the asset properties of the generated Block. Allows you to modify the asset generation of the BlockState, Block Model & Item Model. Eg: TagPrefix.BlockAssetProperties.builder().blockState(ModelHelpers.BlockState::axis).model(ModelHelpers.BlockModel::pillar).build()
  • generationCondition(BiPredicate<Material, TagPrefix> predicate) Whether or not the Prefix should be enabled for a Material. Rutile has some built in conditions that you can use. Setting this to true will enable it for every registered Material.

Builtin Generation Conditions

Rutile has some built in predicates used for enabling / disabling a Prefix. They are located at TagPrefix#Conditions

  • hasFlag(FlagKey<T> key) Returns true if the Material has the specified Flag.
  • hasAnyFlag(FlagKey<?>... keys) Returns true if the Material has any of the specified Flags.
  • hasNoFlag(FlagKey<?>... keys) Returns true if the Material has none of the specified Flags.
  • flagValue(FlagKey<T> key, TriPredicate<Material, TagPrefix, V> valuePredicate) Returns true if the value of the specified FlagKey<UnitFlag<T>> matches the specified predicate.

Builtin Prefixes

Rutile has multiple builtin Prefixes that it uses for its builtin Materials. They are located within RutileTagPrefixes

  • Ingot Generates an Ingot for your Material. Enabled with FlagKey.INGOT.
  • Gem Generates a Gem for your Material. Enabled with FlagKey.GEM.
  • Dust Generates an Ingot for your Material. Enabled with FlagKey.DUST.
  • Nugget Generates a Nugget for your Material. Enabled with FlagKey.INGOT.
  • Block Generates a Storage Block for your Material. Enabled with FlagKey.INGOT OR FlagKey.GEM.
  • RawOre Generates a Raw Ore for your Material. Enabled with FlagKey.ORE WITHOUT FlagKey.GEM.
  • RawOreBlock Generates a Raw Ore Block for your Material. Enabled with FlagKey.ORE WITHOUT FlagKey.GEM.