Datapack Helper Plus is the spiritual successor of pca006132's datapack helper which is only updated to Minecraft: Java Edition 1.13. There are no actual connections between them.
DHP is splitted into two parts: the JSON part and the MCF part. While the former provides supports for all JSON files in a datapack (like advancements, recipes, predicates, loot tables, and tags), the latter provides supports for mcfunction files. The introduction you are reading right now is for the MCF part.
Name | Version | Downloads |
---|---|---|
DHP (JSON) | ||
DHP (MCF) |
- Installation
- Features
- Workspace Support
- Multiple Language Support
- Semantic Highlighting
- Signature Information
- Completions
- Code Snippets
- Definition Comments
- Diagnostics
- Folding Ranges
- Call Hierarchy
- Color Information
- Hover Information
- Resolving Namespaced IDs
- Goto Definitions
- Finding References
- Renaming
- Formatting and Linting
- Configuration Settings
- Regenerating Cache
- Contributors
- Repository Structure
You can install DHP (MCF) from the VSCode Marketplace:
Alternatively, press Ctrl + P and execute ext install spgoding.datapack-language-server
in your VSCode.
Please use the root folder of your datapack (where the data
folder and the pack.mcmeta
file are) as a root folder of your workspace, so that DHP can provide you with the best functionalities.
Moreover, DHP fully supports VSCode's multi-root workspace feature. Every root which contains a data
folder and pack.mcmeta
file will be considered as a datapack and will be used for computing completions. Other root folders will not be affected by DHP.
You can access any content of any root as long as they are in the same workspace. The order of the roots in your workspace will affect the priority of these datapacks in DHP. The root at the beginning will be loaded at first, and the root at the end will be loaded at last, which means that the earlier the root is, the lower priority in DHP it has. This is exactly how Minecraft loads datapacks and decide which one overrides another one if a file has the same namespaced ID and is in the same category. For example, if your multi-root workspace looks like this:
โโโ (Root) Datapack A
โโโ data
| โโโ spgoding
| โโโ functions
| โโโ foo.mcfunction
โโโ pack.mcmeta
โโโ (Root) Datapack B
โโโ data
| โโโ spgoding
| โโโ functions
| โโโ foo.mcfunction
โโโ pack.mcmeta
And then you use F2
in a mcfunction file to renamed the mcfunction spgoding:foo
to wtf:foo
, only the file in Datapack B (Datapack B/data/spgoding/functions/foo.mcfunction
) will be moved to Datapack B/data/wtf/functions/foo.mcfunction
, even if there's a function with the same namespaced ID in Datapack A (Datapack A/data/spgoding/functions/foo.mcfunction
).
If you try to execute these commands in Minecraft, you can also noticed that the function in Datapack B is executed.
datapack enable "file/Datapack A" first
datapack enable "file/Datapack B" last
function spgoding:foo
By acting like this, DHP ensures that the order it handling datapacks is consistent with Minecraft.
Note: you can drag and put the root folders in VSCode to sort them, and DHP will update the priority of them in DHP accordingly, which is really handy.
DHP supports multiple languages. Currently these languages are available:
Language | VSCode Language ID |
---|---|
German | de |
English | en |
French | fr |
Japanese | ja |
Chinese (Simplified) | zh-cn |
If you'd like to help us translate this project into other languages, it would be really appreciated! See CONTRIBUTING.md for more information!
All command arguments should be colored semantically. You can see #308 for a detailed list of all semantic token types and modifiers used by DHP if you are interested in.
Unfortunately, the semantic coloring API of VSCode is still in proposed stage, thus we cannot use it in production environment. All the screenshots below are taken in development mode.
Before VSCode finalizes its API, I recommend to use Arcensoth's language-mcfunction extension for coloring.
You can get hints about the arguments of commands while typing.
The extension can compute completions as you typing commands. Completions will automatically show if you commit one of these characters: [' ', ',', '{', '[', '=', ':', '/', '!', "'", '"', '.', '@']
. Alternatively you can use Ctrl + Space (or other configured hotkey) to show completions manually. Note: completions are not available everywhere. Typically only the beginnings of arguments and literals are supported.
DHP can provide completions for simple commands:
For more complex NBT tags, with the help from mc-nbt-paths contributed by MrYurihi, Levertion and Bassab03:
DHP provides some helpful code snippets. See VSCode's official docs to learn more about code snippets. Both DHP and VSCode allow you to custom your code snippets, and they use exactly the same syntax because DHP is based on VSCode. For mcfunction files, code snippets added by DHP will be shown in the completions list only when the cursor is at the beginning of a command, however snippets added by VSCode's Code/User/snippets/mcfunction.json
file will be shown everywhere in the file. If you want to custom your code snippets via VSCode, see their official docs. If you want to custom snippets via DHP, see the Configuration Settings section.
You can use #define (bossbar|entity|objective|storage|tag|team) <id: string> [<description: string>]
to define a bossbar, an entity, an objective, a data storage, an entity tag, or a team. Definition comments will be used to compute completions, rename symbols and find references/definitions by DHP. The game will treat definition comments as normal comments and simply ignore them.
DHP provides real-time diagnostics about your commands. It can show syntax errors as Minecraft does, and even give your more detailed warnings.
You can use comments (#region
and #endregion
) to create folding ranges, which makes the structure of mcfunction file much clearer.
#region This is a block of commands
execute if score @s test matches 1 run say 1
execute if score @s test matches 2 run say 2
execute if score @s test matches 3 run say 3
execute if score @s test matches 4 run say 4
execute if score @s test matches 5 run say 5
#endregion
Alternatively, you can use different amount of hash symbols followed by at least one white space to create different levels of folding ranges:
#region This is a block of commands
# One
## One - 1
execute if score @s foo matches 1 run say 1
execute if score @s foo matches 2 run say 2
## One - 2
execute if score @s bar matches 1 run say 1
execute if score @s bar matches 2 run say 2
# Two
execute if score @p test matches 1 run say 1
#endregion
This feature is finished by using the proposed API, which is only accessible in development environment.
Call hierarchies are a great way to navigate through functions. You can get all the callers/callees of a function, function tag, or an advancement reward by using this feature. The default hotkey of this feature is Shift + Alt + H
.
DHP will display colors for dust
particles and color
tags in NBTs. You can change the color by hovering your cursor on it.
This is WIP.
DHP shows user-defined documentation when you hover on specific arguments, e.g. on function namespaced IDs, tags, teams, etc.
You can navigate to advancements, loot tables, functions, predicates, and all kinds of tags by Ctrl-clicking on their namespaced IDs.
You can goto the definitions of objectives, entities, tags, teams, bossbars, and data storages in the workspace by Ctrl-clicking on their names.
You can find all the references of objectives, entities, tags, teams, bossbars, data storages, advancements, functions, loot tables, predicates, recipes, and all kinds of datapack tags in the workspace by pressing Shift + F12 or other configured key.
You can rename entities, tags, teams, bossbars, data storages, advancements, functions, loot tables, predicates, recipes, and all kinds of datapack tags by pressing F2 or other configured key on their names.
All the references of the same symbol in the whole workspace will be renamed.
WARNING: your input can be accidentally corrupted by using this feature. Use it at your own risk. You can use the Rename Preview operation provided by VSCode to make sure that nothing is broken before actually renaming.
Additionally, if you rename a namespaced ID with file definition (e.g. the ID for advancement, function, loot table, predicate, recipe or tag), the corresponding file in the workspace will be renamed/moved too.
However, renaming a file in a workspace manually will not update the namespaced IDs of it, and may cause problems with the cache.
You can format the current function by pressing Shift + Alt + F or other configured hotkey.
There are several linting rules you can set in the configuration settings.
WARNING: your input can be accidentally lost by using this feature. Use it at your own risk. This feature is disabled by default. You can enable this feature by changing the datapackLanguageServer.lint.enableFormatting
setting.
Press Ctrl + ,
(or other configured hotkey) to open the Settings page of VSCode, and search datapackLanguageServer
to see all the configuration settings contributed by DHP. You can add your own code snippets, set the lint preferences and environment information to meet your needs. These config can be changed for the current user or the workspace. See VSCode's official docs to learn more about configuring settings.
DHP uses cache to accelerate the process of renaming, finding references/definitions, document links, etc. However, the cache may become outdated because of various reasons, which could lead to strange behaviors. You can use the Datapack: Regenerate Cache
command (ID: datapackLanguageServer.regenerateCache
) to regenerate the cache manually.
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind are welcome!
The exisistence of DHP comes from many other excellent developers! All NPM module dependencies which are installed via NPM can be found in package.json.
Maintains mcdata, a repository that stores the latest data generated by Minecraft's data generator. DHP downloads data from this repository to provide version-specific completions for blocks and registries. See #333 for more details.
Maintains mc-nbtdoc, a repository that stores "machine and human readable documentation for all of Minecraft's in game NBT data". DHP downloads genetated JSON files from this repository to provide completions and validations for version-specific NBT data. See #332 for more details.
Provides Tabula, a lightweight localization tool which is used by DHP to help translate src/locales/en.json
and package.nls.json
.
Designed the DHP's icon and the banner showed on top of this page.
Localization for ๐ฉ๐ช German (de
).
Localization for ๐ซ๐ท French (fr
).
Localization for ๐ฏ๐ต Japanese (ja
).
Localization for ๐จ๐ณ Simplified Chinese (zh-cn
).
SPGoding used to receive financial supports, but there are no ways to sponsor spg anymore.
dist
: Bundled files.client.js
: Stuff related to the client. Only included in the VSCode extension.server.js
: Stuff related to the server. Included in both the VSCode extension and the NPM package.
lib
: TypeScript Declaration (.d.ts
) files. These files are only included in the NPM package.src
: TypeScript source code.