Skip to content

Feature/conditional tags#261

Open
mineLdiver wants to merge 11 commits into
developfrom
feature/conditional-tags
Open

Feature/conditional tags#261
mineLdiver wants to merge 11 commits into
developfrom
feature/conditional-tags

Conversation

@mineLdiver
Copy link
Copy Markdown
Member

Features added:

  • Conditions for tags
  • Targeted tags removal

Conditional tags

Default conditions

stationapi:block_metadata (BlockRegistry)

Makes the tag apply only if the block's metadata matches the one provided in the condition's data.

Data is defined by a single metadata integer field, and can be set via the @metadata shorthand.

Examples

Fully qualified condition:

{
  "values": [
    {
      "id": "example_mod:example_block",
      "conditions": [
        {
          "type": "stationapi:block_metadata",
          "metadata": 15
        }
      ]
    }
  ]
}

Shorthand condition:

{
  "values": [
    "example_mod:example_block@15"
  ]
}

stationapi:item_damage (ItemRegistry)

Makes the tag apply only if the item's damage matches the one provided in the condition's data.

Data is defined by a single damage integer field, and can be set via the @damage shorthand.

Examples

Fully qualified condition:

{
  "values": [
    {
      "id": "example_mod:example_item",
      "conditions": [
        {
          "type": "stationapi:item_damage",
          "damage": 32767
        }
      ]
    }
  ]
}

Shorthand condition:

{
  "values": [
    "example_mod:example_item@32767"
  ]
}

Querying tags

Blocks and items now require additional context when querying tags, for example:

blockState.isIn(tagKey, BlockTagContext.of(world, x, y, z));

Old, context-less methods are still present, but follow these rules:

  • Singular methods (like .isIn(...)) are deprecated and exclude all conditional tags
  • Bulk methods (like .streamTags()) include all conditional tags

Registering a condition

@EventListener
void register(ExampleRegistryEvent event) {
    event.registry
            .buildTagCondition(
                    EXAMPLE_NAMESPACE.id("example_condition"),
                    EXAMPLE_DATA_CODEC, //optional, conditions can require no data
                    ExampleContext::of, // optional, condition logic can operate on generic context
                    (data /* if data codec was provided */, ctx) -> /* condition logic here */
            )
            .shorthand( // optional, can be used for inline condition data
                    Pattern.compile(/* regex pattern for extracting condition data, for example "@(\\d+)" in metadata and damage shorthands */),
                    dynamic -> /* logic for turning the extracted string data into fully qualified condition data that the data codec can parse */
            )
            .register();
}

Targeted tags removal

Tags can now define a remove array to remove previously defined tags (ordered by data priority):
resources/data/minecraft/stationapi/tags/blocks/mineable/pickaxe.json

{
  "remove": [
    "minecraft:stone"
  ]
}

Tag removals use the same schema as tag values, meaning they can be conditional and optional

@mineLdiver mineLdiver added the enhancement New feature or request label Jun 7, 2026
@DanyGames2014
Copy link
Copy Markdown
Contributor

Pls world, x, y, z overrides in block isIn methods, kthxbai

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants