Skip to content

Commit

Permalink
Debug Tools sample (#53)
Browse files Browse the repository at this point in the history
* Debug Tools
  • Loading branch information
mammerla authored Sep 4, 2024
1 parent b33fcb1 commit 4d33c13
Show file tree
Hide file tree
Showing 52 changed files with 6,964 additions and 0 deletions.
3 changes: 3 additions & 0 deletions debug_tools/.env-editor
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJECT_NAME="debug_tools_editor"
MINECRAFT_PRODUCT="PreviewUWP"
CUSTOM_DEPLOYMENT_PATH=""
3 changes: 3 additions & 0 deletions debug_tools/.env-ingame
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PROJECT_NAME="debug_tools_ingame"
MINECRAFT_PRODUCT="PreviewUWP"
CUSTOM_DEPLOYMENT_PATH=""
9 changes: 9 additions & 0 deletions debug_tools/.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
}
7 changes: 7 additions & 0 deletions debug_tools/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"blockceptionltd.blockceptionvscodeminecraftbedrockdevelopmentextension",
"mojang-studios.minecraft-debugger"
]
}
15 changes: 15 additions & 0 deletions debug_tools/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": "0.2.0",
"configurations": [
{
"type": "minecraft-js",
"request": "attach",
"name": "Debug with Minecraft",
"mode": "listen",
"preLaunchTask": "build",
"sourceMapRoot": "${workspaceFolder}/dist/debug/",
"generatedSourceRoot": "${workspaceFolder}/dist/scripts/",
"port": 19144
}
]
}
48 changes: 48 additions & 0 deletions debug_tools/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"git.ignoreLimitWarning": true,
"editor.formatOnSave": true,
"search.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/dist": true,
"**/lib": true
},
"files.exclude": {
"**/.git": true,
"**/.DS_Store": true,
"**/node_modules": true
},
"cSpell.words": [
"Elytra",
"Equippable",
"gametest",
"gametests",
"Ingame",
"knockback",
"mcaddon",
"mcui",
"minecart",
"molang",
"onfire",
"outfile",
"samplelibrary",
"scriptevent",
"shulker",
"skelly",
"zoglin"
],
"editor.tabSize": 2,
"eslint.experimental.useFlatConfig": true
}
17 changes: 17 additions & 0 deletions debug_tools/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "npm: build",
"type": "npm",
"script": "local-deploy"
},
{
"type": "npm",
"script": "mcaddon",
"problemMatcher": [],
"label": "npm: mcaddon",
"detail": "just-scripts mcaddon"
}
]
}
75 changes: 75 additions & 0 deletions debug_tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
page_type: sample
author: mammerla
description: An add-on for Minecraft and the Minecraft Editor for managing debug states and configuration.
ms.author: [email protected]
ms.date: 07/16/2024
languages:
- typescript
products:
- minecraft
---

# Minecraft Debug Tools

This sample contains a set of simple debug tools for adding in-game and editor watches.

## Prerequisites

**Install Node.js tools, if you haven't already**

We're going to use the package manager [npm](https://www.npmjs.com/package/npm) to get more tools to make the process of building our project easier.

Visit [https://nodejs.org/](https://nodejs.org).

Download the version with "LTS" next to the number and install it. (LTS stands for Long Term Support, if you're curious.) In the Node.js Windows installer, accept the installation defaults. You do not need to install any additional tools for Native compilation.

**Install Visual Studio Code, if you haven't already**

Visit the [Visual Studio Code website](https://code.visualstudio.com) and install Visual Studio Code.

## Getting Started

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 parts of our project

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
```

## 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.
20 changes: 20 additions & 0 deletions debug_tools/behavior_packs/common/items/magnifying_glass.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"format_version": "1.20.30",
"minecraft:item": {
"description": {
"identifier": "debug_tools:magnifying_glass",
"category": "Items"
},

"components": {
"minecraft:max_stack_size": 16,
"minecraft:icon": {
"texture": "debug_tools:magnifying_glass"
},
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.weapon.offhand"
}
}
}
}
19 changes: 19 additions & 0 deletions debug_tools/behavior_packs/common/items/wrench.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"format_version": "1.20.30",
"minecraft:item": {
"description": {
"identifier": "debug_tools:wrench",
"category": "Items"
},
"components": {
"minecraft:max_stack_size": 16,
"minecraft:icon": {
"texture": "debug_tools:wrench"
},
"minecraft:wearable": {
"dispensable": true,
"slot": "slot.weapon.offhand"
}
}
}
}
Binary file added debug_tools/behavior_packs/common/pack_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions debug_tools/behavior_packs/debug_tools_editor/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"format_version": 2,
"header": {
"name": "Debug Tools for Editor",
"description": "Tools for debugging projects",
"uuid": "6b6c7b7e-5851-48ef-ae1a-316692c7e737",
"version": [1, 0, 0],
"min_engine_version": [1, 20, 0]
},
"modules": [
{
"description": "Script resources",
"type": "script",
"language": "javascript",
"uuid": "d6ea42d5-2629-4054-ad07-5b2d76ee0524",
"version": [1, 0, 0],
"entry": "scripts/main.js"
}
],
"capabilities": ["editorExtension"],
"dependencies": [
{
"uuid": "81a06565-8345-42eb-8839-4d288bfb6a55",
"version": [1, 0, 0]
},
{
"module_name": "@minecraft/server-editor",
"version": "0.1.0-beta"
},
{
"module_name": "@minecraft/server",
"version": "1.15.0-beta"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.4.0-beta"
}
]
}
34 changes: 34 additions & 0 deletions debug_tools/behavior_packs/debug_tools_ingame/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"format_version": 2,
"header": {
"name": "Debug Tools",
"description": "A gallery of editor code snippets",
"uuid": "45a86633-80d8-49be-adac-9550966e3444",
"version": [1, 0, 0],
"min_engine_version": [1, 20, 0]
},
"modules": [
{
"description": "Script resources",
"type": "script",
"language": "javascript",
"uuid": "e4428aa4-2aeb-4a6a-827e-9219887dd084",
"version": [1, 0, 0],
"entry": "scripts/main.js"
}
],
"dependencies": [
{
"uuid": "499c30a5-224d-4d44-82f6-3aae66b14217",
"version": [1, 0, 0]
},
{
"module_name": "@minecraft/server",
"version": "1.10.0"
},
{
"module_name": "@minecraft/server-ui",
"version": "1.1.0"
}
]
}
20 changes: 20 additions & 0 deletions debug_tools/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: ["scripts/**/*.ts"],
languageOptions: {
parser: tsParser,
ecmaVersion: "latest",
},
plugins: {
ts,
"minecraft-linting": minecraftLinting,
},
rules: {
"minecraft-linting/avoid-unnecessary-command": "error",
},
},
];
Loading

0 comments on commit 4d33c13

Please sign in to comment.