Skip to main content

Minecraft Version (Meta Condition Type)

Checks the Minecraft version the game is running. It ignores its context entirely, so the same type works wherever a condition does (entity, bi-entity, item, block, damage, fluid and biome) and in a power's load_condition. That is where it is most useful: a data pack that ships one set of files for several game versions can drop the branch that this version couldn't parse.

Type ID: apoli:minecraft_version

Fields

FieldTypeDefaultDescription
versionStringoptionalA version name such as 1.21 or 1.20.1, compared with comparison.
data_versionIntegeroptionalThe world data version (3465 on 1.20.1, 3955 on 1.21.1), compared with comparison.
comparisonComparison>=How the running version is compared with version or data_version.

At least one of version and data_version must be given, and with neither the condition never passes. Give both and both have to match.

version is compared one group of numbers at a time, so 1.9 is older than 1.10 and 1.21 is older than 1.21.1. Snapshot names such as 24w03a don't order against release names at all, so use data_version when you need to catch one.

note

The game version never changes while the game runs, so this is worked out once, when the JSON is read. Testing it every tick costs nothing.

Examples

"condition": {
    "type": "apoli:minecraft_version",
    "version": "1.21"
}

This passes on 1.21 and newer. Add "inverted": true for the other half of the split.

{
  "type": "apoli:multiple",
  "modern_dust": {
    "type": "apoli:particle",
    "particle": { "type": "minecraft:dust", "color": [0.62, 0.82, 1.0], "scale": 0.8 },
    "load_condition": { "type": "apoli:minecraft_version", "version": "1.21" }
  },
  "legacy_dust": {
    "type": "apoli:particle",
    "particle": { "type": "minecraft:dust", "params": "0.62 0.82 1.0 0.8" },
    "load_condition": { "type": "apoli:minecraft_version", "version": "1.21", "inverted": true }
  }
}

One coloured dust particle, written in both spellings. Exactly one sub-power survives the reload, and the other's particle field is never handed to a codec that would reject it.

"load_condition": {
    "type": "apoli:minecraft_version",
    "data_version": 3837,
    "comparison": ">="
}

This uses the data version instead, which orders snapshots correctly.