Skip to content

Language server for Minecraft: Java Edition datapacks.

License

Notifications You must be signed in to change notification settings

Ghoulboy78/datapack-language-server

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

banner

Discord CircleCI npm VSCode Marketplace VSCode Marketplace Downloads VSCode Marketplace Installs VSCode Marketplace Rating Codecov License semantic-release Gitmoji

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) VSCode Marketplace VSCode Marketplace Downloads
DHP (MCF) VSCode Marketplace VSCode Marketplace Downloads

Installation

You can install DHP (MCF) from the VSCode Marketplace: VSCode Marketplace

Alternatively, press Ctrl + P and execute ext install spgoding.datapack-language-server in your VSCode.

Features

Workspace Support

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.

Multiple Language Support

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!

Semantic Highlighting

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.

Signature Information

You can get hints about the arguments of commands while typing.

signature-help

Completions

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: simple-completions

For more complex NBT tags, with the help from mc-nbt-paths contributed by MrYurihi, Levertion and Bassab03: nbt-tag-completions

And also NBT paths: nbt-path-completions

Code Snippets

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.

code-snippets

Definition Comments

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.

definition-comments

Diagnostics

DHP provides real-time diagnostics about your commands. It can show syntax errors as Minecraft does, and even give your more detailed warnings.

diagnostics

Folding Ranges

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

folding-ranges

Call Hierarchy

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.

call-hierarchy

Color Information

DHP will display colors for dust particles and color tags in NBTs. You can change the color by hovering your cursor on it.

color-information

Hover Information

This is WIP.

DHP shows user-defined documentation when you hover on specific arguments, e.g. on function namespaced IDs, tags, teams, etc.

Resolving Namespaced IDs

You can navigate to advancements, loot tables, functions, predicates, and all kinds of tags by Ctrl-clicking on their namespaced IDs.

document-link

Goto Definitions

You can goto the definitions of objectives, entities, tags, teams, bossbars, and data storages in the workspace by Ctrl-clicking on their names.

goto-definition

Finding References

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.

peek-references

Renaming

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.

rename-objective

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.

rename-function

However, renaming a file in a workspace manually will not update the namespaced IDs of it, and may cause problems with the cache.

Formatting and Linting

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.

formatting

Configuration Settings

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.

Regenerating Cache

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.

Contributors

Thanks goes to these wonderful people (emoji key):


SPGoding

๐Ÿ’ป ๐ŸŒ

MrYurihi

โฌ†๏ธ ๐Ÿค”

Levertion

๐Ÿ“–

Bassab03

๐Ÿ“–

BlackNight0315

๐ŸŽจ

MarsCloud

๐Ÿ’ป ๐Ÿ’ ๐Ÿ›

switefaster

๐Ÿ’

Heyu

๐Ÿ’

RicoloveFeng

๐Ÿ’

uuu2011

๐Ÿ’

็ˆฑๅ‘็”ต็”จๆˆท_4vCR

๐Ÿ’

ๅค็™ฝๅƒๅฑ‚ๅฟƒ

๐Ÿ’

MCSugar_cane

๐Ÿ’

่™ซๅฐๅ“ฅ

๐Ÿ’

Craft_Kevin

๐Ÿ’

้™Œไฝ™Oucher

๐Ÿ’

้พ™่…พ็Œซ่ทƒ

๐Ÿ’

pca006132

๐Ÿค”

Arcensoth

โฌ†๏ธ ๐Ÿค” ๐Ÿ›

fedpol1

๐Ÿค”

ruhuasiyu

๐Ÿ› ๐Ÿค”

mathaym25

๐Ÿ› ๐Ÿค”

MulverineX

๐Ÿ› ๐Ÿค”

Yijun Yuan

๐Ÿ›

MinecraftPeace

๐Ÿ›

K-bai

๐Ÿ›

ChenCMD

๐Ÿ› ๐Ÿค” ๐ŸŒ

TouchFisha

๐Ÿ›

ๅพก้พ™ไน็ง‹

๐Ÿ›

RevonZev

๐Ÿ›

OctupusTea

๐Ÿ›

00ll00

๐Ÿ›

้›ช้ขœใฎ้กพ

๐Ÿ›

Jokey_้’ฅๅŒ™

๐Ÿ›

MineCommander

๐Ÿ›

้š้€€

๐Ÿ›

Chelove_C60

๐Ÿ›

brooke_zb

๐Ÿ›

dragon3025

๐Ÿ›

Misode

โฌ†๏ธ ๐Ÿ›

Feierwoerx
๐ŸŒ

TCasseBloc
๐ŸŒ

This project follows the all-contributors specification. Contributions of any kind are welcome!

dependency-npm_modules

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.

dependency-Arcensoth

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.

dependency-MrYurihi

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.

dependency-Misode

Provides Tabula, a lightweight localization tool which is used by DHP to help translate src/locales/en.json and package.nls.json.

design-BlackNight0315

Designed the DHP's icon and the banner showed on top of this page.

localization-Feierwoerx

Localization for ๐Ÿ‡ฉ๐Ÿ‡ช German (de).

localization-TCasseBloc

Localization for ๐Ÿ‡ซ๐Ÿ‡ท French (fr).

localization-ChenCMD

Localization for ๐Ÿ‡ฏ๐Ÿ‡ต Japanese (ja).

localization-SPGoding

Localization for ๐Ÿ‡จ๐Ÿ‡ณ Simplified Chinese (zh-cn).

sponsor

SPGoding used to receive financial supports, but there are no ways to sponsor spg anymore.

Repository Structure

  • 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.

About

Language server for Minecraft: Java Edition datapacks.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 99.8%
  • JavaScript 0.2%