Skip to content

selectorSortKeys

SPGoding edited this page Apr 26, 2020 · 1 revision

Rule Details

⚠️ Diagnostic: this is a diagnostic rule used by the diagnostic feature.

🔧 Fixable: violations of this rule can be fixed by Code Actions.

Enforce the values in an entity selector to be sorted by the keys.

  • (string[]): sorted by the specific order. Values ending with Neg will be used to sort the negative version of that type. e.g. type represents type=xxx, while typeNeg represents type=!xxx. Please make sure that all the possible keys are mentioned in the setting, or they might lose after you perform code actions!

Examples

Default

{
    "selectorSortKeys": null
}

👍 Good

kill @e[type=minecraft:zombie, tag=foo]
kill @e[tag=foo, type=minecraft:zombie]

Performance

This is partially based on the research by vdvman1 at https://minecraftcommands.github.io/commanders-handbook/selector-argument-order.

{
    "selectorSortKeys": [
        "warning", 
        [
            "sort", "limit",
            "type", "gamemode", "gamemodeNeg", "level", "team", "teamNeg", 
            "typeNeg", "tag", "tagNeg", "name", "nameNeg", "predicate", "predicateNeg",
            "scores", "advancements", "nbt", "nbtNeg",
            "x", "y", "z", "dx", "dy", "dz", "distance", "x_rotation", "y_rotation"
        ]
    ]
}

👍 Good

kill @e[type=minecraft:zombie, tag=foo]

👎 Bad

kill @e[tag=foo, type=minecraft:zombie]

History

This rule was introduced in DHP 2.0.0.

Clone this wiki locally