-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Editor sample updates
- Loading branch information
Showing
32 changed files
with
8,216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
PROJECT_NAME="editor-multi" | ||
MINECRAFT_PRODUCT="PreviewUWP" | ||
CUSTOM_DEPLOYMENT_PATH="" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"trailingComma": "es5", | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": false, | ||
"bracketSpacing": true, | ||
"arrowParens": "always", | ||
"printWidth": 120, | ||
"endOfLine": "auto" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"recommendations": [ | ||
"esbenp.prettier-vscode", | ||
"blockceptionltd.blockceptionvscodeminecraftbedrockdevelopmentextension", | ||
"mojang-studios.minecraft-debugger" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
"**/dist": true, | ||
"**/lib": true, | ||
"**/.DS_Store": true, | ||
"**/node_modules": true | ||
}, | ||
"cSpell.words": [ | ||
"Elytra", | ||
"Equippable", | ||
"gametest", | ||
"gametests", | ||
"knockback", | ||
"mcaddon", | ||
"mcui", | ||
"minecart", | ||
"molang", | ||
"onfire", | ||
"samplelibrary", | ||
"scriptevent", | ||
"shulker", | ||
"skelly", | ||
"zoglin" | ||
], | ||
"editor.tabSize": 2, | ||
"eslint.experimental.useFlatConfig": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "build", | ||
"type": "shell", | ||
"command": "npm run build" | ||
}, | ||
{ | ||
"label": "deploy", | ||
"type": "shell", | ||
"command": "npm run local-deploy" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
--- | ||
page_type: sample | ||
author: mammerla | ||
description: A comprehensive gallery of different examples of Minecraft Editor plugins. Based on https://github.com/Mojang/minecraft-editor-extension-starter-kit | ||
ms.author: [email protected] | ||
ms.date: 08/24/2024 | ||
languages: | ||
- typescript | ||
products: | ||
- minecraft | ||
--- | ||
|
||
# Minecraft Editor Multiple Plugin Gallery | ||
|
||
This sample contains many code snippets that show how you can manipulate basic Minecraft behaviors. Based on https://github.com/Mojang/minecraft-editor-extension-starter-kit. | ||
|
||
## 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 . | ||
``` | ||
|
||
### Chapter 2. Let's test the parts of our project | ||
|
||
Within the root folder (howto-gallery) 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 | ||
``` | ||
|
||
Create an addon file to share. | ||
|
||
```powershell | ||
npm run mcaddon | ||
``` | ||
|
||
## Manifest | ||
|
||
- [just.config.ts](https://github.com/microsoft/minecraft-scripting-samples/blob/main/howto-gallery/just.config.ts): This file contains build instructions for just-scripts, for building out TypeScript code. | ||
- [scripts](https://github.com/microsoft/minecraft-scripting-samples/blob/main/howto-gallery/scripts): This contains Editor Plugin TypeScript files, that will be compiled and built into your projects. | ||
- [behavior_packs](https://github.com/microsoft/minecraft-scripting-samples/blob/main/howto-gallery/behavior_packs): This contains resources and JSON files that define your behavior pack. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"format_version": 2, | ||
"header": { | ||
"name": "Minecraft Editor Multiple Plugin", | ||
"description": "A gallery of editor code snippets", | ||
"uuid": "2fb88d39-e589-4e49-a69f-f575f8705e5c", | ||
"version": [1, 0, 0], | ||
"min_engine_version": [1, 20, 0] | ||
}, | ||
"modules": [ | ||
{ | ||
"description": "Script resources", | ||
"type": "script", | ||
"language": "javascript", | ||
"uuid": "df6523d1-4442-45c2-b33a-1c882d388683", | ||
"version": [1, 0, 0], | ||
"entry": "scripts/main.js" | ||
} | ||
], | ||
"capabilities": ["editorExtension"], | ||
"dependencies": [ | ||
{ | ||
"uuid": "b3d35b27-1827-4bff-bdf5-694942cfdd25", | ||
"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" | ||
} | ||
] | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
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, | ||
DEFAULT_CLEAN_DIRECTORIES, | ||
getOrThrowFromProcess, | ||
watchTask, | ||
} from "@minecraft/core-build-tasks"; | ||
|
||
import { BuildSnippetsParameters, buildSnippets } from "./tasks/BuildSnippets"; | ||
|
||
// Setup env variables | ||
setupEnvironment(path.resolve(__dirname, ".env")); | ||
const projectName = getOrThrowFromProcess("PROJECT_NAME"); | ||
|
||
const bundleTaskOptions: BundleTaskParameters = { | ||
entryPoint: path.join(__dirname, "./scripts/main.ts"), | ||
external: ["@minecraft/server", "@minecraft/server-gametest", "@minecraft/server-ui", "@minecraft/server-editor"], | ||
outfile: path.resolve(__dirname, "./dist/scripts/main.js"), | ||
minifyWhitespace: false, | ||
sourcemap: true, | ||
outputSourcemapPath: path.resolve(__dirname, "./dist/debug"), | ||
}; | ||
|
||
const copyTaskOptions: CopyTaskParameters = { | ||
copyToBehaviorPacks: [`./behavior_packs/${projectName}`], | ||
copyToScripts: ["./dist/scripts"], | ||
copyToResourcePacks: [`./resource_packs/${projectName}`], | ||
}; | ||
|
||
const mcaddonTaskOptions: ZipTaskParameters = { | ||
...copyTaskOptions, | ||
outputFile: `./dist/packages/${projectName}.mcaddon`, | ||
}; | ||
|
||
// Lint | ||
task("lint", coreLint(["scripts/**/*.ts"], argv().fix)); | ||
|
||
// Build | ||
task("typescript", tscTask()); | ||
task("bundle", bundleTask(bundleTaskOptions)); | ||
task("build", series("typescript", "bundle")); | ||
|
||
// Clean | ||
task("clean-local", cleanTask(DEFAULT_CLEAN_DIRECTORIES)); | ||
task("clean-collateral", cleanCollateralTask(STANDARD_CLEAN_PATHS)); | ||
task("clean", parallel("clean-local", "clean-collateral")); | ||
|
||
// Package | ||
task("copyArtifacts", copyTask(copyTaskOptions)); | ||
task("package", series("clean-collateral", "copyArtifacts")); | ||
|
||
// 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( | ||
["scripts/**/*.ts", "behavior_packs/**/*.{json,lang,png}", "resource_packs/**/*.{json,lang,png}"], | ||
series("clean-local", "build", "package") | ||
) | ||
); | ||
|
||
// Mcaddon | ||
task("createMcaddonFile", mcaddonTask(mcaddonTaskOptions)); | ||
task("mcaddon", series("clean-local", "build", "createMcaddonFile")); | ||
|
||
task( | ||
"buildSnippets", | ||
buildSnippets({ | ||
scriptPaths: [`./scripts/`], | ||
targetFolderPath: "dist/snippets", | ||
}) | ||
); |
Oops, something went wrong.