Skip to content

Code Actions

SPGoding edited this page Nov 12, 2020 · 8 revisions

Introduction

Code actions is a way to provide quickfixes and refactor operations for your commands.

code-action

Toggle

You can toggle the datapack.features.codeActions setting to enable/disable code actions of DHP.

List of Code Actions

Key Name Ex. Before Ex. After
block-state-sort-keys Sort block state - To the order specified in datapack.lint.blockStateSortKeys
command-replaceitem Update this command to /item ... replace replaceitem entity @s hotbar.0 stone item entity @s hotbar.0 replace stone
fix-file Fix all auto-fixable problems in this file A lot of errors. Less errors in this file.
fix-workspace Fix all auto-fixable problems in the workspace A lot of errors. Less errors in the workspace.
id-attribute-datafix Update this attribute name to 1.16 "generic.maxHealth" "generic.max_health"
id-complete-default-namespace Complete default namespace foo minecraft:foo
id-create-file Create %0% in the same data pack A file that doesn't exist. The file is created.
id-omit-default-namespace Omit default namespace minecraft:foo foo
id-zombified-piglin-datafix Change this ID to Zombified Piglin's zombie_pigman zombified_piglin
nbt-compound-sort-keys Sort NBT compound tag - To the order specified in datapack.lint.nbtCompoundSortKeys
nbt-type-to-byte Convert to an NBT byte tag 1 1b
nbt-type-to-double Convert to an NBT double tag 1 1d
nbt-type-to-float Convert to an NBT float tag 1 1f
nbt-type-to-int Convert to an NBT int tag 1s 1
nbt-type-to-long Convert to an NBT long tag 1 1L
nbt-type-to-short Convert to an NBT short tag 1 1s
nbt-uuid-datafix Update this UUID to 1.16 {UUIDMost:1L,UUIDLeast:2L} {UUID:[I;0,1,0,2]}
selector-sort-keys Sort selector argument - To the order specified in datapack.lint.selectorSortKeys
string-double-quote Quote this string with double quotation marks 'foo' "foo"
string-single-quote Quote this string with single quotation marks "foo" 'foo'
string-unquote Unquote this string "foo" foo
vector-align-0.0 Align this vector to block origin 1.2 3 4 1.2 3.0 4.0
vector-align-0.5 Align this vector to block center 1.2 3 4 1.2 3.5 4.5

History

Version Description
2.0.0 Added block-state-sort-keys, id-attribute-datafix, id-complete-default-namespace, id-omit-default-namespace, nbt-compound-sort-keys, nbt-type-to-byte, nbt-type-to-double, nbt-type-to-float, nbt-type-to-int, nbt-type-to-long, nbt-type-to-short, nbt-uuid-datafix, selector-sort-keys, string-double-quote, string-single-quote, string-unquote, vector-align-0.0, and vector-align-0.5.
2.1.0 Added fix-file, fix-workspace, and id-zombified-piglin-datafix.
3.0.0 Added id-create-file.
3.1.0 Added command-replaceitem.
Clone this wiki locally