MicrosoftDocs / minecraft-creator

This is the repository for Minecraft Bedrock documentation.
Creative Commons Attribution 4.0 International
175 stars 130 forks source link

The @minecraft/vanilla-data module does not work #903

Open Rasim100 opened 1 month ago

Rasim100 commented 1 month ago

[Enter feedback here]

I am trying to throw the minecraft/vanilla-data module into the json manifest dependency, format version 2, when starting the game, it gives an error that an unknown module is dependent. Although npm i @minecraft/vanilla-data worked and I have the necessary module. Why is this happening and how do I use this module to work with vanilla items?

Here is the whole code of the manifest: { "format_version": 2, "header": { "name": "Dynamic Trees BP", "description": "Made by New Perspectives company", "min_engine_version": [1,21,0], "uuid": "6c4a594d-d1f7-4577-8d17-23c19327a9e4", "version": [1,0,0] }, "modules": [ { "description": "Made by New Perspectives company", "type": "data", "uuid": "96a695d6-5deb-44ae-8cb2-7ebb832abea2", "version": [1,0,0] }, { "description": "This is script module", "type": "script", "language": "Javascript", "uuid": "da00b5f6-4ca1-4457-900f-60f600314bd6", "entry": "scripts/main.js", "version": [1,0,0] } ], "dependencies": [ { "uuid": "2f711ca7-69ed-4859-823f-572710c3b10f", "version": [1,0,0] }, { "module_name": "@minecraft/server", "version": "1.11.0" }, { "module_name": "@minecraft/server-ui", "version": "1.2.0-beta" }, { "module_name": "@minecraft/server-gametest", "version": "1.0.0-beta" }, { "module_name": "@minecraft/vanilla-data", "version": "1.21.3" } ] }

Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Visual1mpact commented 3 weeks ago

vanilla-data is not an actual module. Remove it from the manifest. You have to download it using NPM and bundle it with your behavior pack. Your scripts which depends on it will need to target the correct path. It must be located within the scripts folder of your behavior pack.

Zabadam commented 1 week ago

vanilla-data is not an actual module. Remove it from the manifest. You have to download it using NPM and bundle it with your behavior pack. Your scripts which depends on it will need to target the correct path. It must be located within the scripts folder of your behavior pack.

This is an excellent response but could be even better it it explained how one bundles the npm i assets.

Visual1mpact commented 4 days ago

vanilla-data is not an actual module. Remove it from the manifest. You have to download it using NPM and bundle it with your behavior pack. Your scripts which depends on it will need to target the correct path. It must be located within the scripts folder of your behavior pack.

This is an excellent response but could be even better it it explained how one bundles the npm i assets.

I bundle npm assets like @minecraft/math manually to ensure better control over file structures and avoid potential conflicts between modules. Using a custom script (copy-modules.js), I copy essential modules from node_modules into a specific directory. For certain modules like @minecraft/math, I also move and rename files, such as math-public.d.ts, to ensure smooth integration with TypeScript - rare cases. This process runs automatically after installing dependencies via an npm postinstall hook, making it efficient and reliable. A similar approach can be applied to bundle other modules like @minecraft/vanilla-data.

Some like to use something such as webpack or similar. Personal preference, however I do not use any such tools so I can't give guidance on it. I handle the bundling on my own accord.

https://github.com/Visual1mpact/Paradox_AntiCheat/blob/rewrite/package.json