Skip to content

Update to Minecraft 1.21+ and better build process #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env-editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJECT_NAME="debug_stick_editor"
MINECRAFT_PRODUCT="BedrockUWP"
CUSTOM_DEPLOYMENT_PATH=""
3 changes: 3 additions & 0 deletions .env-ingame
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJECT_NAME="debug_stick_ingame"
MINECRAFT_PRODUCT="BedrockUWP"
CUSTOM_DEPLOYMENT_PATH=""
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ debug-stick.mcpack
node_modules
package-lock.json
pack/scripts/*
lib/
dist/
9 changes: 9 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"trailingComma": "es5",
"tabWidth": 2,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"arrowParens": "always",
"printWidth": 120
}
59 changes: 56 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Similar to Java Edition, you can:
This add-on has been tested and functions correctly with Minecraft: Bedrock
Edition 1.20.0 and above.

### How to Obtain
## How to Obtain

- Download the add-on from the [releases section][releases] or directly [here][dl].
- Import the add-on into Minecraft.
Expand All @@ -42,13 +42,66 @@ experimental toggle is no longer required.

- Some block properties from Minecraft Java Edition are not accessible.

### Contribution

## How to Build Add-On

1. Use npm to install dependent modules:

```powershell
npm i
```

1. Use this shortcut command to open the project in Visual Studio Code:

```powershell
code .
```

### Running the Add-On

Within the root folder (debug_tools) of this sample, run this command:

```powershell
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
```

Run this one to deploy in the game.

```powershell
npm run local-deploy
```

If you'd like to run deployment in a watch mode, run the following:

```powershell
npm run local-deploy -- --watch
```

Run this one to deploy in the editor mode.

```powershell
npm run local-deploy-editor
```

Building the `.mcaddon` and `.mcpack`:

```powershell
npm run mcaddon
```

## Contribution

Feel free to contribute to the add-on.

### License
## License

Copyright © 2023-2025 Vincent Yanzee J. Tan. Licensed under the MIT License.

[releases]: https://github.com/vytdev/debug-stick/releases
[dl]: https://github.com/vytdev/debug-stick/releases/latest/download/debug-stick.mcpack

## Manifest

- [just.config.ts](https://github.com/microsoft/minecraft-samples/blob/main/debug_tools/just.config.ts): This file contains build instructions for just-scripts, for building out TypeScript code.
- [scripts](https://github.com/microsoft/minecraft-samples/blob/main/debug_tools/scripts): This contains Debug Tools TypeScript files, that will be compiled and built into your projects.
- [behavior_packs](https://github.com/microsoft/minecraft-samples/blob/main/debug_tools/behavior_packs): This contains resources and JSON files that define your behavior pack.
23 changes: 23 additions & 0 deletions behavior_packs/common/items/debug_stick.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"format_version": "1.20.20",
"minecraft:item": {
"description": {
"identifier": "vyt:debug_stick",
"menu_category": {
"category": "items"
}
},
"components": {
"minecraft:icon": {
"texture": "stick"
},
"minecraft:hand_equipped": true,
"minecraft:display_name": {
"value": "§dDebug Stick§r"
},
"minecraft:max_stack_size": 1,
"minecraft:can_destroy_in_creative": false,
"minecraft:glint": true
}
}
}
File renamed without changes
45 changes: 45 additions & 0 deletions behavior_packs/debug_stick_editor/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"format_version": 2,

"header": {
"name": "Debug Stick",
"description": "Java §dDebug Stick§r ported to Minecraft: Bedrock Edition, by §bvytdev§r\nUse §a/give @s vyt:debug_stick§r or find it in the inventory screen to obtain the item.\n\nReport bugs here: §bhttps://github.com/vytdev/debug-stick/§r\nCopyright (c) 2023-2025 Vincent Yanzee J. Tan\nLicensed under the MIT License.",
"uuid": "11c582c1-a87f-4c8f-b6de-77b65b400738",
"version": "1.13.0",
"min_engine_version": [ 1, 21, 60 ]
},

"modules": [
{
"description": "Behaviour",
"type": "data",
"uuid": "ead47941-848b-4d77-8a31-11a036878237",
"version": [ 1, 0, 0 ]
},
{
"description": "scripting",
"type": "script",
"language": "javascript",
"entry": "scripts/main.js",
"uuid": "4076907f-4ff5-4fde-8b7a-f2f96963832b",
"version": [ 1, 0, 0 ]
}
],
"capabilities": ["editorExtension"],
"dependencies": [
{
"uuid": "32b99a24-7323-464d-9a21-e631ef306664",
"version": [1, 0, 0]
},
{
"module_name": "@minecraft/server",
"version": "1.18.0-beta"
}
],

"metadata": {
"authors": [ "VYT" ],
"license": "MIT",
"url": "https://github.com/vytdev/debug-stick"
}
}
40 changes: 40 additions & 0 deletions behavior_packs/debug_stick_ingame/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"format_version": 2,

"header": {
"name": "Debug Stick",
"description": "Java §dDebug Stick§r ported to Minecraft: Bedrock Edition, by §bvytdev§r\nUse §a/give @s vyt:debug_stick§r or find it in the inventory screen to obtain the item.\n\nReport bugs here: §bhttps://github.com/vytdev/debug-stick/§r\nCopyright (c) 2023-2025 Vincent Yanzee J. Tan\nLicensed under the MIT License.",
"uuid": "21aadfa6-e27c-400c-c596-596021852939",
"version": "1.13.0",
"min_engine_version": [ 1, 21, 60 ]
},

"modules": [
{
"description": "behaviour",
"type": "data",
"uuid": "d8a9ff21-7aa3-4b83-73ed-eeb141516e74",
"version": [ 1, 0, 0 ]
},
{
"description": "scripting",
"type": "script",
"language": "javascript",
"entry": "scripts/main.js",
"uuid": "86c7bab4-aed9-4297-5f0c-d5d62bd30be1",
"version": [ 1, 0, 0 ]
}
],
"dependencies": [
{
"module_name": "@minecraft/server",
"version": "1.18.0-beta"
}
],

"metadata": {
"authors": [ "VYT" ],
"license": "MIT",
"url": "https://github.com/vytdev/debug-stick"
}
}
20 changes: 20 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import minecraftLinting from "eslint-plugin-minecraft-linting";
import tsParser from "@typescript-eslint/parser";
import ts from "@typescript-eslint/eslint-plugin";

export default [
{
files: ["src/**/*.ts"],
languageOptions: {
parser: tsParser,
ecmaVersion: "latest",
},
plugins: {
ts,
"minecraft-linting": minecraftLinting,
},
rules: {
"minecraft-linting/avoid-unnecessary-command": "error",
},
},
];
128 changes: 128 additions & 0 deletions just.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { argv, parallel, series, task, tscTask } from "just-scripts";
import path from "path";

import {
bundleTask,
BundleTaskParameters,
CopyTaskParameters,
cleanTask,
cleanCollateralTask,
copyTask,
coreLint,
mcaddonTask,
setupEnvironment,
ZipTaskParameters,
STANDARD_CLEAN_PATHS,
watchTask,
} from "@minecraft/core-build-tasks";

// Setup env variables
function setEnvIngame() {
setupEnvironment(path.resolve(__dirname, ".env-ingame"));
}

function setEnvEditor() {
setupEnvironment(path.resolve(__dirname, ".env-editor"));
}

const bundleIngameTaskOptions: BundleTaskParameters = {
entryPoint: path.join(__dirname, "./src/index.ts"),
external: ["@minecraft/server", "@minecraft/server-ui"],
outfile: path.resolve(__dirname, "./dist/ingame/scripts/main.js"),
minifyWhitespace: false,
sourcemap: true,
outputSourcemapPath: path.resolve(__dirname, "./dist/ingame/debug"),
};

const bundleEditorTaskOptions: BundleTaskParameters = {
entryPoint: path.join(__dirname, "./src/index.ts"),
external: ["@minecraft/server", "@minecraft/server-gametest", "@minecraft/server-ui", "@minecraft/server-editor"],
outfile: path.resolve(__dirname, "./dist/editor/scripts/main.js"),
minifyWhitespace: false,
sourcemap: true,
outputSourcemapPath: path.resolve(__dirname, "./dist/editor/debug"),
};

const copyTaskIngameOptions: CopyTaskParameters = {
copyToBehaviorPacks: [`./behavior_packs/debug_stick_ingame`, `./behavior_packs/common`],
copyToScripts: ["./dist/ingame/scripts"],
copyToResourcePacks: [`./resource_packs/debug_stick_ingame`, `./resource_packs/common`],
};

const copyTaskEditorOptions: CopyTaskParameters = {
copyToBehaviorPacks: [`./behavior_packs/debug_stick_editor`, `./behavior_packs/common`],
copyToScripts: ["./dist/editor/scripts"],
copyToResourcePacks: [`./resource_packs/debug_stick_editor`, `./resource_packs/common`],
};

const mcaddonTaskIngameOptions: ZipTaskParameters = {
...copyTaskIngameOptions,
outputFile: `./dist/packages/debug_stick_ingame.mcaddon`,
};

const mcaddonTaskEditorOptions: ZipTaskParameters = {
...copyTaskEditorOptions,
outputFile: `./dist/packages/debug_stick_editor.mcaddon`,
};

// Lint
task("lint", coreLint(["src/**/*.ts"], argv().fix));

// Build
task(
"typescript-editor",
tscTask({
project: "tsconfig.editor.json",
})
);

task(
"typescript-ingame",
tscTask({
project: "tsconfig.ingame.json",
})
);

task("setEnvIngame", setEnvIngame);
task("setEnvEditor", setEnvEditor);

task("bundle-ingame", bundleTask(bundleIngameTaskOptions));
task("bundle-editor", bundleTask(bundleEditorTaskOptions));

task("build-ingame", series("typescript-ingame", "bundle-ingame"));
task("build-editor", series("typescript-editor", "bundle-editor"));

// Clean
task("clean-local-editor", cleanTask(["lib/editor", "dist/editor"]));
task("clean-local-ingame", cleanTask(["lib/ingame", "dist/ingame"]));
task("clean-collateral-usingenv", cleanCollateralTask(STANDARD_CLEAN_PATHS));
task("clean", parallel("clean-local-editor", "clean-local-ingame", "clean-collateral-usingenv"));

// Package
task("copyArtifacts-ingame", series(setEnvIngame, copyTask(copyTaskIngameOptions)));
task("copyArtifacts-editor", series(setEnvEditor, copyTask(copyTaskEditorOptions)));

task("package-ingame", series("clean-collateral-usingenv", "copyArtifacts-ingame"));
task("package-editor", series("clean-collateral-usingenv", "copyArtifacts-editor"));

// Local Deploy used for deploying local changes directly to output via the bundler. It does a full build and package first just in case.
task(
"local-deploy",
watchTask(
["src/**/*.ts", "behavior_packs/**/*.{json,lang,png}", "resource_packs/**/*.{json,lang,png}"],
series(setEnvIngame, "clean-local-ingame", "build-ingame", "package-ingame")
)
);
task(
"local-deploy-editor",
watchTask(
["src/**/*.ts", "behavior_packs/**/*.{json,lang,png}", "resource_packs/**/*.{json,lang,png}"],
series("setEnvEditor", "clean-local-editor", "build-editor", "package-editor")
)
);

// Mcaddon
task("create-ingame-mcaddon-file", series(setEnvIngame, mcaddonTask(mcaddonTaskIngameOptions)));
task("create-editor-mcaddon-file", series(setEnvEditor, mcaddonTask(mcaddonTaskEditorOptions)));

task("mcaddon", series("clean-local-ingame", "build-ingame", "create-ingame-mcaddon-file"));
25 changes: 0 additions & 25 deletions pack.py

This file was deleted.

Loading
Loading