From 22147562e989dfb1c7aae2a4120f1a2c1c9d8e6e Mon Sep 17 00:00:00 2001 From: jj136975 Date: Wed, 26 Feb 2025 13:56:52 +0100 Subject: [PATCH 1/3] Update to Minecraft 1.21.60 and Upgrade build process --- .env-editor | 3 + .env-ingame | 3 + .gitignore | 2 + .prettierrc.json | 9 ++ README.md | 53 +++++++- behavior_packs/common/items/debug_stick.json | 23 ++++ {pack => behavior_packs/common}/pack_icon.png | Bin .../debug_stick_editor/manifest.json | 45 ++++++ .../debug_stick_ingame/manifest.json | 40 ++++++ eslint.config.mjs | 20 +++ just.config.ts | 128 ++++++++++++++++++ pack.py | 25 ---- pack/items/debug_stick.json | 27 ---- pack/manifest.json | 42 ------ package.json | 19 ++- resource_packs/common/pack_icon.png | Bin 0 -> 522 bytes .../debug_stick_editor/manifest.json | 25 ++++ .../debug_stick_ingame/manifest.json | 25 ++++ src/index.ts | 37 +++-- tsconfig.editor.json | 36 +++++ tsconfig.ingame.json | 36 +++++ 21 files changed, 482 insertions(+), 116 deletions(-) create mode 100644 .env-editor create mode 100644 .env-ingame create mode 100644 .prettierrc.json create mode 100644 behavior_packs/common/items/debug_stick.json rename {pack => behavior_packs/common}/pack_icon.png (100%) create mode 100644 behavior_packs/debug_stick_editor/manifest.json create mode 100644 behavior_packs/debug_stick_ingame/manifest.json create mode 100644 eslint.config.mjs create mode 100644 just.config.ts delete mode 100644 pack.py delete mode 100644 pack/items/debug_stick.json delete mode 100644 pack/manifest.json create mode 100644 resource_packs/common/pack_icon.png create mode 100644 resource_packs/debug_stick_editor/manifest.json create mode 100644 resource_packs/debug_stick_ingame/manifest.json create mode 100644 tsconfig.editor.json create mode 100644 tsconfig.ingame.json diff --git a/.env-editor b/.env-editor new file mode 100644 index 0000000..a73de45 --- /dev/null +++ b/.env-editor @@ -0,0 +1,3 @@ +PROJECT_NAME="debug_stick_editor" +MINECRAFT_PRODUCT="BedrockUWP" +CUSTOM_DEPLOYMENT_PATH="" \ No newline at end of file diff --git a/.env-ingame b/.env-ingame new file mode 100644 index 0000000..70ebacf --- /dev/null +++ b/.env-ingame @@ -0,0 +1,3 @@ +PROJECT_NAME="debug_stick_ingame" +MINECRAFT_PRODUCT="BedrockUWP" +CUSTOM_DEPLOYMENT_PATH="" \ No newline at end of file diff --git a/.gitignore b/.gitignore index 7e94acf..4679fb4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,5 @@ debug-stick.mcpack node_modules package-lock.json pack/scripts/* +lib/ +dist/ \ No newline at end of file diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..6077332 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,9 @@ +{ + "trailingComma": "es5", + "tabWidth": 2, + "semi": true, + "singleQuote": false, + "bracketSpacing": true, + "arrowParens": "always", + "printWidth": 120 +} \ No newline at end of file diff --git a/README.md b/README.md index 53aee26..a3cc329 100644 --- a/README.md +++ b/README.md @@ -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. @@ -42,13 +42,60 @@ 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 +``` + +## 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. \ No newline at end of file diff --git a/behavior_packs/common/items/debug_stick.json b/behavior_packs/common/items/debug_stick.json new file mode 100644 index 0000000..c413e72 --- /dev/null +++ b/behavior_packs/common/items/debug_stick.json @@ -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 + } + } +} \ No newline at end of file diff --git a/pack/pack_icon.png b/behavior_packs/common/pack_icon.png similarity index 100% rename from pack/pack_icon.png rename to behavior_packs/common/pack_icon.png diff --git a/behavior_packs/debug_stick_editor/manifest.json b/behavior_packs/debug_stick_editor/manifest.json new file mode 100644 index 0000000..9e721a6 --- /dev/null +++ b/behavior_packs/debug_stick_editor/manifest.json @@ -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" + } + } \ No newline at end of file diff --git a/behavior_packs/debug_stick_ingame/manifest.json b/behavior_packs/debug_stick_ingame/manifest.json new file mode 100644 index 0000000..5dbc2df --- /dev/null +++ b/behavior_packs/debug_stick_ingame/manifest.json @@ -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" + } + } \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..58da649 --- /dev/null +++ b/eslint.config.mjs @@ -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", + }, + }, +]; \ No newline at end of file diff --git a/just.config.ts b/just.config.ts new file mode 100644 index 0000000..9f5734e --- /dev/null +++ b/just.config.ts @@ -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-ingame", series("clean-local-ingame", "build-ingame", "create-ingame-mcaddon-file")); \ No newline at end of file diff --git a/pack.py b/pack.py deleted file mode 100644 index 051fa14..0000000 --- a/pack.py +++ /dev/null @@ -1,25 +0,0 @@ -import os -import zipfile -import pathlib - -srcdir = "pack" -output_name = "debug-stick.mcpack" - -print("Packaging .mcpack add-on...") - -with zipfile.ZipFile(output_name, "w", zipfile.ZIP_DEFLATED) as zipf: - - # iterate over all files - for root, dirs, files in os.walk(srcdir): - - # relative path to src folder - relroot = pathlib.Path(root).relative_to(srcdir) - - # files within src folder - for file in files: - zipf.write(os.path.join(root, file), relroot / file) - - # add the license file - zipf.write("LICENSE") - -print(f"Pack done! At: {output_name}") diff --git a/pack/items/debug_stick.json b/pack/items/debug_stick.json deleted file mode 100644 index 2d64ba5..0000000 --- a/pack/items/debug_stick.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "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 - } - } - -} diff --git a/pack/manifest.json b/pack/manifest.json deleted file mode 100644 index 6df1dc7..0000000 --- a/pack/manifest.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "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, 50 ] - }, - - "modules": [ - { - "description": "behaviour", - "type": "data", - "uuid": "d8a9ff21-7aa3-4b83-73ed-eeb141516e74", - "version": [ 1, 0, 0 ] - }, - { - "description": "scripting", - "type": "script", - "language": "javascript", - "entry": "scripts/index.js", - "uuid": "86c7bab4-aed9-4297-5f0c-d5d62bd30be1", - "version": [ 1, 0, 0 ] - } - ], - - "dependencies": [ - { - "module_name": "@minecraft/server", - "version": "1.17.0-beta" - } - ], - - "metadata": { - "authors": [ "VYT" ], - "license": "MIT", - "url": "https://github.com/vytdev/debug-stick" - } -} - diff --git a/package.json b/package.json index 11e69df..1e1a555 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,14 @@ "version": "1.13.0", "description": "Debug stick for minecraft bedrock", "scripts": { - "test": "npx tsc", - "build": "npx tsc && python pack.py", - "clean": "rm -rf debug-stick.mcpack pack/scripts/*" + "lint": "just-scripts lint", + "build": "just-scripts build", + "clean": "just-scripts clean", + "local-deploy": "just-scripts local-deploy", + "local-deploy-editor": "just-scripts local-deploy-editor", + "mcaddon": "just-scripts mcaddon", + "enablemcloopback": "CheckNetIsolation.exe LoopbackExempt -a -p=S-1-15-2-1958404141-86561845-1752920682-3514627264-368642714-62675701-733520436", + "enablemcpreviewloopback": "CheckNetIsolation.exe LoopbackExempt -a -p=S-1-15-2-424268864-5579737-879501358-346833251-474568803-887069379-4040235476" }, "repository": { "type": "git", @@ -24,7 +29,13 @@ }, "homepage": "https://github.com/vytdev/debug-stick#readme", "dependencies": { - "@minecraft/server": "1.17.0-beta.1.21.51-stable", + "@minecraft/server": "1.18.0-beta.1.21.61-stable" + }, + "devDependencies": { + "@minecraft/core-build-tasks": "^1.1.3", + "eslint-plugin-minecraft-linting": "^1.2.1", + "source-map": "^0.7.4", + "ts-node": "^10.9.1", "typescript": "^5.4.5" } } diff --git a/resource_packs/common/pack_icon.png b/resource_packs/common/pack_icon.png new file mode 100644 index 0000000000000000000000000000000000000000..73fb813de23bb6b873a2ad12dbe155b7a9fde7cb GIT binary patch literal 522 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSEX7WqAsj$Z!;#X#z`%IW)5S5Q zV$R!JhF&UxA`TbBeAtW~XJn|Eni`swPSsm{IkM?t%AtgWq!laQJrF;$edVit&zHD5 zI>yWG`Cq-A8E7I1_?^9ZOa8!(!*{*F8(?*D(UegDUw^)mPpZ z{r#`EPXj^@Y|tELpQu}(>;L~TtoeWb^6d{l-^|;8gau& { const player = getPlayerByID(ev.damagingEntity.id); - if (!isHoldingDebugStick(player)) + if (player == undefined || !isHoldingDebugStick(player)) return; safeCall(changeSelectedProperty, player, ev.hitBlock); @@ -63,6 +64,8 @@ world.beforeEvents.itemUseOn.subscribe((ev) => { const player = getPlayerByID(ev.source.id); + if (player == undefined) return; + if (player.isSneaking) safeCall(displayBlockInfo, player, ev.block); else @@ -94,10 +97,13 @@ function changeSelectedProperty(player: Player, block: Block) { const states = permutation.getAllStates(); const names = Object.keys(states); - if (!names.length && !block.type.canBeWaterlogged) + if (!names.length && !block.canContainLiquid(LiquidType.Water)) return message(`${block.typeId} has no properties`, player); let prop = getCurrentProperty(player, block.typeId); + + if (prop == undefined) return; + let val: BlockStateValue; // Increment for the next property @@ -108,7 +114,7 @@ function changeSelectedProperty(player: Player, block: Block) { // list, check if the 'waterlogged' property is // available, or just go back at the start of the list if (!prop) { - if (block.type.canBeWaterlogged) { + if (block.canContainLiquid(LiquidType.Water)) { prop = "waterlogged"; val = block.isWaterlogged; } @@ -134,18 +140,21 @@ function updateBlockProperty(player: Player, block: Block) { const states = permutation.getAllStates(); const names = Object.keys(states); - if (!names.length && !block.type.canBeWaterlogged) + if (!names.length && !block.canContainLiquid(LiquidType.Water)) return message(`${block.typeId} has no properties`, player); let prop = getCurrentProperty(player, block.typeId); + + if (prop == undefined) return; + let val: BlockStateValue; // Ensure that the recorded block property selection // is available on the block - if (prop == "waterlogged" ? !block.type.canBeWaterlogged : !names.includes(prop)) + if (prop == "waterlogged" ? !block.canContainLiquid(LiquidType.Water) : !names.includes(prop)) prop = names[0]; - if (!prop && block.type.canBeWaterlogged) + if (!prop && block.canContainLiquid(LiquidType.Water)) prop = "waterlogged"; // Update the property value @@ -157,7 +166,7 @@ function updateBlockProperty(player: Player, block: Block) { } else { - const valids = BlockStates.get(prop).validValues; + const valids = BlockStates.get(prop)!.validValues; val = valids[valids.indexOf(states[prop]) + 1]; if (typeof val === "undefined") @@ -207,7 +216,7 @@ function displayBlockInfo(player: Player, block: Block) { }); // Waterlog property if available - if (block.type.canBeWaterlogged) + if (block.canContainLiquid(LiquidType.Water)) info += "\n§o§7waterlogged§r§8: §6" + block.isWaterlogged; // Additional block tags @@ -241,10 +250,7 @@ function message(msg: string, player: Player) { * @returns ItemStack or undefined */ function getHeldItem(player: Player): ItemStack | undefined { - return player - .getComponent("minecraft:inventory") - .container - .getItem(player.selectedSlotIndex); + return player.getComponent("minecraft:inventory")?.container?.getItem(player.selectedSlotIndex); } /** @@ -305,7 +311,7 @@ function setCurrentProperty(player: Player, block: string, val: string): void { function safeCall( func: (...args: A) => R, ...args: A - ): R { + ): R | undefined { try { return func.apply({}, args); @@ -318,9 +324,10 @@ function safeCall( msg += e; - if (e?.stack) + if (e instanceof Error && e.stack) msg += `\n${e.stack}`; console.error(msg); } + return undefined; } diff --git a/tsconfig.editor.json b/tsconfig.editor.json new file mode 100644 index 0000000..b96d300 --- /dev/null +++ b/tsconfig.editor.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "target": "es6", + "moduleResolution": "Node", + "module": "ES2020", + "declaration": false, + "noLib": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "pretty": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "allowUnreachableCode": true, + "allowUnusedLabels": true, + "noImplicitAny": true, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "outDir": "lib/editor", + "rootDir": ".", + "baseUrl": "behavior_packs/", + "listFiles": false, + "noEmitHelpers": true, + "skipLibCheck": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "lib", + "dist", + "node_modules", + "scripts/ingame/**/*" + ], + "compileOnSave": false +} \ No newline at end of file diff --git a/tsconfig.ingame.json b/tsconfig.ingame.json new file mode 100644 index 0000000..4dfad0e --- /dev/null +++ b/tsconfig.ingame.json @@ -0,0 +1,36 @@ +{ + "compilerOptions": { + "target": "es6", + "moduleResolution": "Node", + "module": "ES2020", + "declaration": false, + "noLib": false, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "pretty": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "allowUnreachableCode": true, + "allowUnusedLabels": true, + "noImplicitAny": true, + "noImplicitReturns": false, + "noImplicitUseStrict": false, + "outDir": "lib/ingame", + "rootDir": ".", + "baseUrl": "behavior_packs/", + "listFiles": false, + "noEmitHelpers": true, + "skipLibCheck": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "lib", + "dist", + "node_modules", + "scripts/editor/**/*" + ], + "compileOnSave": false +} \ No newline at end of file From ca8116f5fdfae45f98d8f2eec6a481b9a15104c4 Mon Sep 17 00:00:00 2001 From: jj136975 Date: Wed, 26 Feb 2025 14:03:26 +0100 Subject: [PATCH 2/3] Fix mcaddon build and update README --- README.md | 6 ++++++ just.config.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3cc329..f9bbe38 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,12 @@ Run this one to deploy in the editor mode. npm run local-deploy-editor ``` +Building the `.mcaddon` and `.mcpack`: + +```powershell +npm run mcaddon +``` + ## Contribution Feel free to contribute to the add-on. diff --git a/just.config.ts b/just.config.ts index 9f5734e..01197be 100644 --- a/just.config.ts +++ b/just.config.ts @@ -125,4 +125,4 @@ task( task("create-ingame-mcaddon-file", series(setEnvIngame, mcaddonTask(mcaddonTaskIngameOptions))); task("create-editor-mcaddon-file", series(setEnvEditor, mcaddonTask(mcaddonTaskEditorOptions))); -task("mcaddon-ingame", series("clean-local-ingame", "build-ingame", "create-ingame-mcaddon-file")); \ No newline at end of file +task("mcaddon", series("clean-local-ingame", "build-ingame", "create-ingame-mcaddon-file")); \ No newline at end of file From ad1a2d19a8090894e27381230233ac89699a51df Mon Sep 17 00:00:00 2001 From: jj136975 Date: Wed, 26 Feb 2025 14:24:58 +0100 Subject: [PATCH 3/3] Add block face info --- src/index.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.ts b/src/index.ts index 59ec6be..e6302f1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -21,7 +21,8 @@ import { ItemStack, world, system, - LiquidType + LiquidType, + Direction } from "@minecraft/server"; import { @@ -67,7 +68,7 @@ world.beforeEvents.itemUseOn.subscribe((ev) => { if (player == undefined) return; if (player.isSneaking) - safeCall(displayBlockInfo, player, ev.block); + safeCall(displayBlockInfo, player, ev.block, ev.blockFace); else safeCall(updateBlockProperty, player, ev.block); }); @@ -188,11 +189,11 @@ function updateBlockProperty(player: Player, block: Block) { * @param player * @param block */ -function displayBlockInfo(player: Player, block: Block) { +function displayBlockInfo(player: Player, block: Block, block_face: Direction) { let info = "§l§b" + block.typeId + "§r"; // The block's coordinates - info += "\n§4" + block.x + " §a" + block.y + " §9" + block.z; + info += "\n§4" + block.x + " §a" + block.y + " §9" + block.z + " §7face: " + block_face; // Block's matter state info += "\n§7matter state§8: §e";