From 38459bb379611409214c3b4cd3a375bba5f21b55 Mon Sep 17 00:00:00 2001 From: Mike Ammerlaan Date: Thu, 14 Dec 2023 06:33:47 -0800 Subject: [PATCH] Test updates; VS Code configuration; further trimming --- .gitignore | 2 +- README.md | 43 +- app/.vscode/extensions.json | 5 + app/.vscode/launch.json | 27 + app/.vscode/settings.json | 657 +++++++++++++ app/.vscode/tasks.json | 13 + app/gulpfile.js | 11 +- app/package.json | 3 +- app/public/res/index.json | 6 + app/reslist/packs.resources.json | 2 +- app/src/UX/App.tsx | 52 +- app/src/UX/CodeMinecraftView.css | 39 - app/src/UX/CodeMinecraftView.tsx | 213 ----- app/src/UX/CodeStartPage.css | 50 - app/src/UX/CodeStartPage.tsx | 236 ----- app/src/UX/CodeToolbox.css | 88 -- app/src/UX/CodeToolbox.tsx | 84 -- app/src/UX/CodeToolboxLanding.css | 21 - app/src/UX/CodeToolboxLanding.tsx | 64 -- app/src/UX/JsonEditor.tsx | 2 +- app/src/UX/ProjectEditor.tsx | 13 - app/src/UX/ProjectItemList.css | 1 + app/src/UX/ProjectItemList.tsx | 12 - app/src/app/Carto.ts | 23 +- app/src/app/ProjectItem.ts | 9 - app/src/app/RemoteMinecraft.ts | 456 --------- app/src/autoscript/AutoScript.ts | 165 ---- app/src/autoscript/AutoScriptAction.ts | 233 ----- app/src/autoscript/AutoScriptError.ts | 11 - app/src/autoscript/AutoScriptGroup.ts | 219 ----- app/src/autoscript/AutoScriptScope.ts | 49 - app/src/autoscript/BlockBrokenAction.ts | 96 -- app/src/autoscript/EntitySpawnAction.ts | 94 -- app/src/autoscript/IAutoScriptAction.ts | 11 - app/src/autoscript/IAutoScriptClause.ts | 3 - app/src/autoscript/IAutoScriptClauseGroup.ts | 3 - app/src/autoscript/IAutoScriptData.ts | 5 - app/src/autoscript/IAutoScriptGroup.ts | 5 - app/src/autoscript/ICommandOptions.ts | 3 - app/src/autoscript/ICommandRequirements.ts | 1 - app/src/autoscript/IScriptArea.ts | 7 - app/src/autoscript/IScriptOptions.ts | 5 - app/src/autoscript/IScriptRequirements.ts | 4 - app/src/autoscript/ITestData.ts | 5 - app/src/autoscript/IdleAction.ts | 42 - .../SimulatedPlayerInteractionAction.ts | 92 -- .../autoscript/SimulatedPlayerMoveAction.ts | 90 -- .../autoscript/SimulatedPlayerSpawnAction.ts | 110 --- .../clientapp/MinecraftGameProxyMinecraft.ts | 300 ------ .../clientapp/ProcessHostedProxyMinecraft.ts | 361 ------- app/src/dataform/MinecraftFilter.tsx | 2 +- app/src/gameTest/FenceConnectivity.ts | 26 - app/src/gameTest/SimulatedPlayer.ts | 609 ------------ app/src/gameTest/Test.ts | 902 ------------------ app/src/images/bedrock.png | Bin 278 -> 0 bytes app/src/images/coarse_dirt.png | Bin 609 -> 0 bytes app/src/images/dirt.png | Bin 295 -> 0 bytes app/src/images/mcc_g.png | Bin 7441 -> 0 bytes .../mccb_pattern_green_corner_top_03.png | Bin 1556 -> 0 bytes app/src/local/IAuthenticationToken.ts | 3 - app/src/minecraft/Database.ts | 2 +- app/src/script/AutoScriptManager.ts | 156 --- app/src/script/WorldTestManager.ts | 226 ----- app/src/test/CartoTest.ts | 3 +- app/src/test/CommandLineTest.ts | 262 ----- app/src/tools/BlockStamp.ts | 87 -- app/src/vscodeweb/MessageProxy.ts | 132 --- app/src/vscodeweb/MessageProxyFile.ts | 209 ---- app/src/vscodeweb/MessageProxyFolder.ts | 229 ----- app/src/vscodeweb/MessageProxyStorage.ts | 105 -- app/src/vscodeweb/VsWebLocalUtilities.ts | 97 -- app/src/worldtest/IWorldTestArea.ts | 12 - app/src/worldtest/IWorldTestDefinition.ts | 7 - app/src/worldtest/WorldTest.ts | 91 -- app/src/worldtest/WorldTestArea.ts | 115 --- app/test/scenarios/simple/report.json | 121 +-- .../scripts/generated/LocalWorld.js | 4 - app/test/scenarios/worldCommand/level.dat | Bin 52 -> 0 bytes app/test/scenarios/worldCommand/level.dat_old | Bin 52 -> 0 bytes app/test/scenarios/worldCommand/levelname.txt | 1 - .../DownloadResources.js | 10 +- .../behavior_packs/deployJs/manifest.json | 43 + .../behavior_packs/deployJs}/scripts/index.js | 0 .../deployJs}/scripts/starttests.js | 0 .../StarterTestsTutorial}/manifest.json | 0 .../StarterTestsTutorial}/pack_icon.png | Bin .../StarterTestsTutorial/scripts/index.js | 4 + .../scripts/starttests.js | 20 + .../starttests/mediumglass.mcstructure | Bin 0 -> 9872 bytes 89 files changed, 854 insertions(+), 6670 deletions(-) create mode 100644 app/.vscode/extensions.json create mode 100644 app/.vscode/launch.json create mode 100644 app/.vscode/settings.json create mode 100644 app/.vscode/tasks.json create mode 100644 app/public/res/index.json delete mode 100644 app/src/UX/CodeMinecraftView.css delete mode 100644 app/src/UX/CodeMinecraftView.tsx delete mode 100644 app/src/UX/CodeStartPage.css delete mode 100644 app/src/UX/CodeStartPage.tsx delete mode 100644 app/src/UX/CodeToolbox.css delete mode 100644 app/src/UX/CodeToolbox.tsx delete mode 100644 app/src/UX/CodeToolboxLanding.css delete mode 100644 app/src/UX/CodeToolboxLanding.tsx delete mode 100644 app/src/app/RemoteMinecraft.ts delete mode 100644 app/src/autoscript/AutoScript.ts delete mode 100644 app/src/autoscript/AutoScriptAction.ts delete mode 100644 app/src/autoscript/AutoScriptError.ts delete mode 100644 app/src/autoscript/AutoScriptGroup.ts delete mode 100644 app/src/autoscript/AutoScriptScope.ts delete mode 100644 app/src/autoscript/BlockBrokenAction.ts delete mode 100644 app/src/autoscript/EntitySpawnAction.ts delete mode 100644 app/src/autoscript/IAutoScriptAction.ts delete mode 100644 app/src/autoscript/IAutoScriptClause.ts delete mode 100644 app/src/autoscript/IAutoScriptClauseGroup.ts delete mode 100644 app/src/autoscript/IAutoScriptData.ts delete mode 100644 app/src/autoscript/IAutoScriptGroup.ts delete mode 100644 app/src/autoscript/ICommandOptions.ts delete mode 100644 app/src/autoscript/ICommandRequirements.ts delete mode 100644 app/src/autoscript/IScriptArea.ts delete mode 100644 app/src/autoscript/IScriptOptions.ts delete mode 100644 app/src/autoscript/IScriptRequirements.ts delete mode 100644 app/src/autoscript/ITestData.ts delete mode 100644 app/src/autoscript/IdleAction.ts delete mode 100644 app/src/autoscript/SimulatedPlayerInteractionAction.ts delete mode 100644 app/src/autoscript/SimulatedPlayerMoveAction.ts delete mode 100644 app/src/autoscript/SimulatedPlayerSpawnAction.ts delete mode 100644 app/src/clientapp/MinecraftGameProxyMinecraft.ts delete mode 100644 app/src/clientapp/ProcessHostedProxyMinecraft.ts delete mode 100644 app/src/gameTest/FenceConnectivity.ts delete mode 100644 app/src/gameTest/SimulatedPlayer.ts delete mode 100644 app/src/gameTest/Test.ts delete mode 100644 app/src/images/bedrock.png delete mode 100644 app/src/images/coarse_dirt.png delete mode 100644 app/src/images/dirt.png delete mode 100644 app/src/images/mcc_g.png delete mode 100644 app/src/images/mccb_pattern_green_corner_top_03.png delete mode 100644 app/src/script/AutoScriptManager.ts delete mode 100644 app/src/script/WorldTestManager.ts delete mode 100644 app/src/test/CommandLineTest.ts delete mode 100644 app/src/tools/BlockStamp.ts delete mode 100644 app/src/vscodeweb/MessageProxy.ts delete mode 100644 app/src/vscodeweb/MessageProxyFile.ts delete mode 100644 app/src/vscodeweb/MessageProxyFolder.ts delete mode 100644 app/src/vscodeweb/MessageProxyStorage.ts delete mode 100644 app/src/vscodeweb/VsWebLocalUtilities.ts delete mode 100644 app/src/worldtest/IWorldTestArea.ts delete mode 100644 app/src/worldtest/IWorldTestDefinition.ts delete mode 100644 app/src/worldtest/WorldTest.ts delete mode 100644 app/src/worldtest/WorldTestArea.ts delete mode 100644 app/test/scenarios/worldCommand/behavior_packs/worldcommand/scripts/generated/LocalWorld.js delete mode 100644 app/test/scenarios/worldCommand/level.dat delete mode 100644 app/test/scenarios/worldCommand/level.dat_old delete mode 100644 app/test/scenarios/worldCommand/levelname.txt create mode 100644 tests/deployJs/behavior_packs/deployJs/manifest.json rename {app/test/scenarios/deployCommand/development_behavior_packs/simple => tests/deployJs/behavior_packs/deployJs}/scripts/index.js (100%) rename {app/test/scenarios/deployCommand/development_behavior_packs/simple => tests/deployJs/behavior_packs/deployJs}/scripts/starttests.js (100%) rename {app/test/scenarios/deployCommand/development_behavior_packs/simple => tests/simple/behavior_packs/StarterTestsTutorial}/manifest.json (100%) rename {app/test/scenarios/deployCommand/development_behavior_packs/simple => tests/simple/behavior_packs/StarterTestsTutorial}/pack_icon.png (100%) create mode 100644 tests/simple/behavior_packs/StarterTestsTutorial/scripts/index.js create mode 100644 tests/simple/behavior_packs/StarterTestsTutorial/scripts/starttests.js create mode 100644 tests/simple/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure diff --git a/.gitignore b/.gitignore index f3ec1aea..a1cfd7b1 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ dist/ node_modules/ app/public/data/typedefs.beta.json app/public/data/typedefs.stable.json -app/public/res/latest/van/ +app/public/res/latest/ /~$ app/nod # misc diff --git a/README.md b/README.md index d6c273ff..6e05eef9 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,30 @@ -# Minecraft Creator Tools v0.1.49 +# Minecraft Creator Tools v0.1.63 -Web-, command-line-, and application-based tools for Minecraft creators. +This is project is a work in progress for a set of web-based tools for Minecraft Creators. -Visit the [documentation](https://silver-guide-3a7f4789.pages.github.io/docs/) for more information on everything you can do with Minecraft Creator Tools. +Visit the [documentation](https://mctools.dev/docs/) for more information on Minecraft Creator Tools and the current set of capabilities. -See the [changelog](CHANGELOG.md) for detailed updates and notes. If you have issues, contact mikeam or create a [GitHub issue](https://github.com/Mojang/minecraft-developer-tools/issues). +See the [changelog](CHANGELOG.md) for detailed updates and notes. If you have issues, please create a [GitHub issue](https://github.com/Mojang/minecraft-creator-tools/issues). See the [Project Structure](ProjectStructure.md) file for a look at the structure of the codebase including a tour of major types. ## Using Creator Tools -Visit this web app via . - -(this app is published to GitHub pages (), but works better. - -To use the Windows application, Visual Studio Code extension, command line tools, or server manager, visit the [releases](https://github.com/Mojang/minecraft-developer-tools/releases) page. +Visit this web app via . Enjoy! ## GitHub Repo & Developer Getting Started -Most everything (Windows App; VSCode Extension; web site; Node.js-based command line tools) is built out of the `web` folder. +Everything is built out of the `app` folder. In the `app\` folder, run ```dotnetcli -buildall.cmd -``` - -This will then in turn run: - -```dotnetcli -npm i +npm run all ``` -to install dependencies. - -Then, it will run: - -```dotnetcli -npm run devenv -``` - -This will install additional dependencies and resources. - -From there, it will build the web, JS Node (JSN), Visual Studio Code (VSC), and Windows app builds. +to install dependencies and resources. ## Available Scripts @@ -53,7 +33,7 @@ In the project directory, you can run: ### `npm start` \ `npm run web` Runs the app in the development mode. -Open [http://localhost:3000?debug=true](http://localhost:3000?debug=true) to view it in the browser. +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. **_ IMPORTANT - note the extra URL params above. _** @@ -72,8 +52,3 @@ See the section about [running tests](https://facebook.github.io/create-react-ap Builds the web app for production to the `build` folder. It correctly bundles React in production mode and optimizes the build for the best performance. The build is minified and the filenames include the hashes. - -### `npm run jsnbuild` - -Builds the node package/command line tool/self-hostable Minecraft server site to the `toolbuild\jsn` folder. Run `npm run jsncorebuild` for a shorter build of just the Node-side components (no UX web build.) - diff --git a/app/.vscode/extensions.json b/app/.vscode/extensions.json new file mode 100644 index 00000000..3433c01b --- /dev/null +++ b/app/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/app/.vscode/launch.json b/app/.vscode/launch.json new file mode 100644 index 00000000..d9f543ee --- /dev/null +++ b/app/.vscode/launch.json @@ -0,0 +1,27 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "type": "pwa-chrome", + "request": "launch", + "name": "Launch Chrome against localhost", + "url": "http://localhost:3000", + "webRoot": "${workspaceFolder}" + }, + { + "type": "node", + "request": "launch", + "name": "Mocha tests", + "program": "${workspaceFolder}/node_modules/ts-mocha/bin/ts-mocha", + "preLaunchTask": "gulp: jsncorebuild", + "args": [ + "-p", "tsconfig.test.json", + "-delay", + "--no-timeouts", + "--colors", + "${workspaceFolder}/src/test/**/*.ts" + ], + "internalConsoleOptions": "openOnSessionStart" + } + ] +} \ No newline at end of file diff --git a/app/.vscode/settings.json b/app/.vscode/settings.json new file mode 100644 index 00000000..b5c10986 --- /dev/null +++ b/app/.vscode/settings.json @@ -0,0 +1,657 @@ +{ + "git.ignoreLimitWarning": true, + "editor.formatOnSave": true, + //"typescript.preferences.importModuleSpecifierEnding": "js", + //"javascript.preferences.importModuleSpecifierEnding": "js", + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode" + }, + "files.exclude": { + "**/build": true, + "**/toolbuild": true, + "**/out": true, + "**/dist": true, + "**/min-maps": true, + "**/res": true, + "**/node_modules": true, + "**/jsn": true, + "**/web": true, + "**/vsc": true, + "**/app/bin": true, + "**/.vscode-test-web": true + }, + "cSpell.words": [ + "accesory", + "actorprefix", + "ADDONIREQ", + "advgrid", + "AETFLS", + "AETVA", + "aghr", + "allf", + "anims", + "apphelp", + "appsvc", + "appweb", + "armorstand", + "asae", + "asar", + "ASGE", + "asyncclose", + "asyncdedicated", + "asyncexecute", + "asyncget", + "asynclog", + "asyncminecraft", + "asyncopen", + "asyncreload", + "asyncselect", + "asyncshell", + "asyncshow", + "asyncstart", + "asyncstop", + "asyncupdate", + "asyncweb", + "asyncwindow", + "attachables", + "attackmobs", + "attackplayers", + "autodeployment", + "autogen", + "autogenerated", + "autoscript", + "autoscripting", + "autostartlabel", + "autotest", + "autotests", + "backupinput", + "backuplabel", + "BASEGAMEVER", + "baseUri", + "bbwe", + "behaviorpackmanifest", + "betaapis", + "bigints", + "bisize", + "bitem", + "BOUNDINGSPHERE", + "bpack", + "BPENTITYTYPE", + "bpme", + "bpscriptentrypoint", + "bpuniqueidinput", + "bpuniqueidlabel", + "bpuuid", + "Brushable", + "BTNCU", + "btype", + "buttonbar", + "camerashake", + "cand", + "canonicalization", + "canonicalize", + "carto", + "cartobackup", + "CBEC", + "CBEDC", + "CBNCU", + "changesetting", + "char", + "chestplate", + "cinematics", + "clearspawnpoint", + "clientapp", + "clusterize", + "codeminecraftview", + "codepoint", + "colorpicker", + "commandblockoutput", + "commandblocksenabled", + "commandsblocksenabled", + "commandtools", + "Compactable", + "companyshortname", + "comparr", + "componentized", + "contentlog", + "Cooldown", + "coolgame", + "cracked_polishedblackstone_bricks", + "ctgh", + "ctlr", + "ctool", + "ctype", + "CULLINGSTRATEGY", + "cutscene", + "darksp", + "dataform", + "datauniqueidinput", + "datauniqueidlabel", + "DAWATA", + "DAWATAB", + "DAWATAC", + "DAWATAD", + "DAWATAE", + "daylock", + "dbitem", + "DCEC", + "dclass", + "dcommand", + "dcomme", + "dcse", + "dedicatedserve", + "dedicatedserverpanel", + "defaultbehaviorpackfolder", + "DEFAULTSIDE", + "delim", + "denum", + "deop", + "deploytestworld", + "deploytoremote", + "deploytoserver", + "Descrip", + "Descript", + "descriptioninput", + "descriptionlabel", + "devenv", + "devproject", + "DFKOASFPC", + "digp", + "dinos", + "directserverpath", + "displaySslProps", + "dlres", + "Doced", + "docfx", + "dodaylightcycle", + "doentitydrops", + "dofiretick", + "doimmediaterespawn", + "doinsomnia", + "domobloot", + "domobspawning", + "doorsandswitches", + "dotiledrops", + "DOUBLESIDE", + "doweathercycle", + "dptw", + "drowningdamage", + "dsee", + "DSEEC", + "dssp", + "dtitem", + "DWTR", + "ebugger", + "editorbin", + "editorgrid", + "editorsearchinput", + "Elec", + "elytra", + "EMWF", + "ensureworld", + "entityadder", + "entityselector", + "envprefs", + "EPFFC", + "equippable", + "Equivs", + "errorable", + "ERRORHELP", + "ETBPF", + "ETNCU", + "eved", + "experimentalgameplay", + "exportaddon", + "exportworld", + "falldamage", + "fela", + "fexcf", + "fexfid", + "fexfo", + "fexfod", + "firedamage", + "flatcreativegt", + "flatpack", + "flatworldlayers", + "flav", + "fluentui", + "fontawesome", + "forminput", + "fortawesome", + "FPAA", + "freezedamage", + "frompath", + "FRONTSIDE", + "functioncommandlimit", + "furnitures", + "gamemode", + "Gameplay", + "Gamertags", + "gamerule", + "gametest", + "gametestinstance", + "gametestjs", + "gametests", + "gameteststructure", + "gametype", + "gametypeinput", + "gametypelabel", + "GBAU", + "geninput", + "genlabel", + "getset", + "ghpath", + "ghre", + "ghurl", + "glowstone", + "GPNH", + "gulpfile", + "healability", + "HETC", + "HNMA", + "humanify", + "i", + "iaccept", + "iagree", + "iagreeinput", + "iagreelabel", + "iconplaceholder", + "id", + "Illager", + "Initted", + "initting", + "inpt", + "inputpermission", + "insta", + "instabuild", + "INTERNALERR", + "iseditorinput", + "iseditorlabel", + "isloaded", + "itemlist", + "ITNCU", + "javacat", + "JSEP", + "jsindex", + "jsnbuild", + "jsnbuildfilesigs", + "jsncorebuild", + "jsnode", + "jsnweb", + "jsnwebbuild", + "jsnwebbuildfilesigs", + "jsnwebindex", + "jsonify", + "jsonlang", + "Jsons", + "JSONTAGS", + "jszip", + "jszipo", + "keepinventory", + "keyname", + "knockback", + "labelcell", + "last", + "lasta", + "lastbt", + "lastmb", + "lastml", + "latestbetascriptversion", + "latlng", + "leasher", + "leveldat", + "LEVELDATOLD", + "levelname", + "LEVELNAMETXT", + "lightsp", + "Lngs", + "localforage", + "logitemarea", + "longerjson", + "mainapp", + "mainhand", + "manifestjson", + "manip", + "maparea", + "maxcommandchainlength", + "mcaddon", + "mcbetatypedefsigs", + "mcbuild", + "mcbuildsigs", + "mcc", + "mccat", + "mcconnect", + "mcdev", + "mcfe", + "mcfunction", + "mcpack", + "mcpacks", + "mcpreview", + "mcproject", + "mcreslistsigs", + "mcstabletypedefsigs", + "mcstructure", + "mct", + "mctauth", + "mctbackup", + "mctdeploy", + "mctemplate", + "mctools", + "mctpacks", + "mctpc", + "mctprefs", + "mctprojects", + "mcttools", + "mctvbackup", + "mctworking", + "mctworlds", + "mctypes", + "mcui", + "mcuwp", + "mcwe", + "mcworld", + "mcworlds", + "mdwpanel", + "mifi", + "mificl", + "mima", + "MINENGINEVER", + "minigames", + "mnpm", + "mobevent", + "mobevents", + "mobgriefing", + "mobparty", + "modcontent", + "modeinput", + "modelabel", + "molang", + "mshblk", + "mult", + "nameinput", + "namelabel", + "naturalregeneration", + "netease", + "netherbricks", + "netherite", + "newpro", + "newproject", + "nodebuffer", + "nodeify", + "noeditor", + "northstar", + "notemplate", + "Noto", + "npcs", + "npmdepends", + "npme", + "NPMJS", + "numarr", + "nums", + "octo", + "octokit", + "OFCU", + "onfire", + "onpropertychanged", + "opencontainers", + "openfolderbutton", + "oper", + "packbin", + "packlabel", + "PACKMETADATA", + "packslabel", + "Packument", + "paeonia", + "pako", + "Passcode", + "passcodes", + "pathing", + "pathinput", + "pathlabel", + "pbitem", + "pcinput", + "pcki", + "pclabel", + "pcmn", + "pdbitem", + "pdisp", + "permessage", + "persistable", + "PESMC", + "phserver", + "piid", + "PISGFP", + "pitem", + "playanimation", + "playsound", + "polishedblackstone", + "portinput", + "portlabel", + "portv", + "positionless", + "postclean", + "prefs", + "prid", + "prismarine", + "projectitem", + "projectname", + "projectshortname", + "protogs", + "Pseudoterminal", + "ptgh", + "purpur", + "PURU", + "PURUP", + "pwitem", + "pwmess", + "randomizealluids", + "randomtickspeed", + "rauschma", + "recents", + "redownloaded", + "regen", + "Regs", + "Reloadable", + "relpath", + "removeplayer", + "replaceitem", + "repo", + "repos", + "rescan", + "reslist", + "resourcepackmanifest", + "respawnblocksexplode", + "respawnblocksexpode", + "rideability", + "rpack", + "rpuniqueidinput", + "rpuniqueidlabel", + "rpuuid", + "rshift", + "rssp", + "runtests", + "samplelibrary", + "sarr", + "sarrt", + "sarry", + "SCHM", + "scriptbox", + "SCRIPTMODULE", + "scriptuniqueidinput", + "scriptuniqueidlabel", + "SDSC", + "searchview", + "searchviewcontainer", + "seedinput", + "seedlabel", + "selectionarea", + "sendcommandfeedback", + "servermanager", + "servermanagerht", + "setblock", + "setmaxplayers", + "setnewestformatversions", + "setnewestminengineversion", + "setpasscode", + "setserver", + "setsrv", + "Settings", + "setworldspawn", + "showbordereffect", + "showcoordinates", + "showdeathmessages", + "showtags", + "Shulker", + "signin", + "simplayer", + "simulatedplayer", + "singleline", + "skelly", + "skinpackmanifest", + "Skyblock", + "slargs", + "slotcountinput", + "slotcountlabel", + "snbt", + "sourceserverpath", + "spath", + "spawnable", + "spawnpoint", + "spawnradius", + "spawnx", + "spawny", + "spawnz", + "splitbutton", + "spma", + "spreadplayers", + "starterbp", + "stheader", + "stonebricks", + "stopsound", + "stringio", + "Strs", + "struct", + "structs", + "structure", + "structuretemplate", + "Subbar", + "SUBCHUNK", + "subchunks", + "sublink", + "subloading", + "subpacks", + "sugg", + "summonable", + "surr", + "swellgame", + "swtoggex", + "tallgrass", + "tameability", + "tatmpdata", + "tbar", + "teleporter", + "tellraw", + "templatebin", + "templatelabel", + "templateslabel", + "testc", + "testfor", + "testforblock", + "testforblocks", + "TESTSUB", + "texed", + "texturepack", + "threed", + "threedarea", + "tickingarea", + "titlebar", + "titleraw", + "tmmn", + "tntexplodes", + "toggledownfall", + "toolbuild", + "toolset", + "topath", + "Travelled", + "tsdoc", + "tslang", + "typedefs", + "typestr", + "uids", + "ukey", + "UNKFILE", + "UNKJSON", + "unmaximize", + "unsub", + "usemanifestversionscript", + "usepackageversionscript", + "usepreviewinput", + "usepreviewlabel", + "uxcat", + "uxex", + "Vals", + "vanilladata", + "Varint", + "versioninput", + "versioninputline", + "versionlabel", + "versionMajor", + "vscbuild", + "vsccore", + "vsccorebuild", + "vsccorebuildfilesigs", + "vsccoreexebuild", + "vsccoreweb", + "vsccorewebbuild", + "VSCODEFILE", + "vscodeweb", + "vscweb", + "vscwebbuild", + "vscwebbuildfilesigs", + "vscwebindex", + "VSFS", + "watchvsccore", + "webbuild", + "Webviews", + "wekyb", + "WHOLEFILE", + "wido", + "widos", + "wmspanel", + "WORLDDATA", + "worldsettingslabel", + "worldtemplatemanifest", + "worldtest", + "worldux", + "wsevent", + "wslabel", + "wsserver", + "wtae", + "wtmanifest", + "Xmark", + "Xrow", + "xuid", + "yxxx", + "zoglin" + ], + "mochaExplorer.files": "src/test/**/*.ts", + "mochaExplorer.require": "ts-node/register", + "mochaExplorer.nodeArgv": [ + "--loader=ts-node/esm", + "--no-warnings=ExperimentalWarning", + "--experimental-specifier-resolution=node" + ], + "editor.tabSize": 2 +} diff --git a/app/.vscode/tasks.json b/app/.vscode/tasks.json new file mode 100644 index 00000000..f06701a3 --- /dev/null +++ b/app/.vscode/tasks.json @@ -0,0 +1,13 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "build", + "group": "build", + "problemMatcher": [], + "label": "npm: build", + "detail": "react-scripts --max_old_space_size=8192 build" + } + ] +} \ No newline at end of file diff --git a/app/gulpfile.js b/app/gulpfile.js index c4fd45ee..4d849383 100644 --- a/app/gulpfile.js +++ b/app/gulpfile.js @@ -80,7 +80,8 @@ const mcbetatypedefsigs = [ "node_modules/@minecraft/server-net/*.d.ts", ]; -const mcreslistsigs = ["reslist/*.resources.json"]; +const mcreslistsigs = ["reslist/schemas.resources.json"]; +const mcreslistvanillasigs = ["reslist/packs.resources.json"]; function compileVscCoreExeBuild() { return gulp @@ -351,7 +352,11 @@ function buildStableJsonTypeDefs() { } function runDownloadResources() { - return gulp.src(mcreslistsigs, { base: "" }).pipe(downloadResources("public/res/latest/van/")); + return gulp.src(mcreslistsigs, { base: "" }).pipe(downloadResources("public/res/latest/")); +} + +function runDownloadVanillaResources() { + return gulp.src(mcreslistvanillasigs, { base: "" }).pipe(downloadResources("public/res/latest/van/")); } gulp.task("vscwebbuild", gulp.series("clean-vscwebbuild", compileVscWebBuild, "postclean-vscwebbuild")); @@ -368,7 +373,7 @@ gulp.task("mcbuild", gulp.series(gulp.parallel("clean-mcbuild", "webbuild"), bui gulp.task("mctypes", gulp.parallel(buildBetaJsonTypeDefs, buildStableJsonTypeDefs)); -gulp.task("dlres", gulp.series(runDownloadResources, copyCheckedInRes)); +gulp.task("dlres", gulp.parallel(runDownloadResources, runDownloadVanillaResources, copyCheckedInRes)); gulp.task("devenv", gulp.parallel("mctypes", "dlres", copyMonacoNpmDist)); diff --git a/app/package.json b/app/package.json index 1c29a031..26207398 100644 --- a/app/package.json +++ b/app/package.json @@ -57,9 +57,8 @@ "web": "react-scripts --max_old_space_size=16384 start", "start": "react-scripts --max_old_space_size=16384 start", "webbuild": "react-scripts --max_old_space_size=16384 build", - "jsnbuild": "gulp jsnbuild", "jsncorebuild": "gulp jsncorebuild", - "all": "npm install && npm run-script devenv && npm run-script webbuild", + "all": "npm install && npm run-script devenv && npm run-script webbuild && npm run-script jsncorebuild", "test": "ts-mocha -delay -p tsconfig.test.json src/test/**/*.ts", "test-ci": "ts-mocha -delay -p tsconfig.test.json src/test/**/*.ts --reporter json > test/test-results.json", "eject": "react-scripts eject" diff --git a/app/public/res/index.json b/app/public/res/index.json new file mode 100644 index 00000000..67f44f71 --- /dev/null +++ b/app/public/res/index.json @@ -0,0 +1,6 @@ +{ + "files": [], + "folders": [ + "latest" + ] +} \ No newline at end of file diff --git a/app/reslist/packs.resources.json b/app/reslist/packs.resources.json index f5f7fc09..f8dce675 100644 --- a/app/reslist/packs.resources.json +++ b/app/reslist/packs.resources.json @@ -1,5 +1,5 @@ { "url": "https://github.com/Mojang/bedrock-samples/archive/refs/heads/main.zip", "ignoreSubfolder": "bedrock-samples-main", - "exclude": ["documentation/", "scripts/", "trading/", "pack_icon.png", "manifest.json"] + "exclude": ["documentation/", "scripts/", "trading/", "pack_icon.png", ".github", "manifest.json"] } diff --git a/app/src/UX/App.tsx b/app/src/UX/App.tsx index edaa24ca..004267ca 100644 --- a/app/src/UX/App.tsx +++ b/app/src/UX/App.tsx @@ -13,16 +13,13 @@ import Log from "../core/Log"; import { ProjectFocus, ProjectScriptLanguage } from "../app/IProjectData"; import CartoApp, { HostType } from "../app/CartoApp"; import StorageUtilities from "../storage/StorageUtilities"; -import CodeToolbox from "./CodeToolbox"; import { ThemeInput } from "@fluentui/react-northstar"; import { CartoEditorViewMode } from "../app/ICartoData"; import MCWorld from "../minecraft/MCWorld"; -import CodeStartPage from "./CodeStartPage"; import ProjectItem from "../app/ProjectItem"; import Utilities from "../core/Utilities"; import ZipStorage from "../storage/ZipStorage"; import ProjectUtilities from "../app/ProjectUtilities"; -import CodeToolboxLanding from "./CodeToolboxLanding"; import ProjectExporter from "../app/ProjectExporter"; import ProjectUpdateRunner from "../updates/ProjectUpdateRunner"; import { LocalFolderType, LocalGalleryCommand } from "./LocalGalleryCommand"; @@ -1148,7 +1145,6 @@ export default class App extends Component { let top = <>; let borderStr = ""; let height = "100vh"; - let heightOffset = 0; if (this.state.mode === AppMode.loading) { let message = "loading..."; @@ -1177,48 +1173,6 @@ export default class App extends Component { onProjectSelected={this._handleProjectSelected} /> ); - } else if (this.state.mode === AppMode.codeToolbox) { - interior = ( - - ); - } else if (this.state.mode === AppMode.codeStartPage) { - interior = ( - - ); - } else if (this.state.mode === AppMode.codeStartPageForceNewProject) { - interior = ( - - ); - } else if (this.state.mode === AppMode.codeLandingForceNewProject) { - interior = ( - - ); } else if (this.state.mode === AppMode.home) { interior = ( { project={this.state.activeProject} mode={ProjectEditorMode.inspector} viewMode={CartoEditorViewMode.mainFocus} - readOnly={isReadOnly} + readOnly={true} onModeChangeRequested={this._handleModeChangeRequested} /> ); @@ -1296,7 +1250,7 @@ export default class App extends Component { project={this.state.activeProject} mode={this.state.initialProjectEditorMode ? this.state.initialProjectEditorMode : undefined} selectedItem={this.state.selectedItem} - readOnly={isReadOnly} + readOnly={true} onModeChangeRequested={this._handleModeChangeRequested} /> ); @@ -1308,7 +1262,7 @@ export default class App extends Component { project={this.state.activeProject} mode={this.state.initialProjectEditorMode ? this.state.initialProjectEditorMode : undefined} selectedItem={this.state.selectedItem} - readOnly={isReadOnly} + readOnly={true} onModeChangeRequested={this._handleModeChangeRequested} /> ); diff --git a/app/src/UX/CodeMinecraftView.css b/app/src/UX/CodeMinecraftView.css deleted file mode 100644 index 3ad6a981..00000000 --- a/app/src/UX/CodeMinecraftView.css +++ /dev/null @@ -1,39 +0,0 @@ -.cmv-outer { - min-width: 100%; - max-width: 100%; - min-height: 100vh; - max-height: 100vh; - display: grid; -} - -.cmv-loading { - padding: 5px; - padding-left: 20px; - padding-right: 20px; -} - -.cmv-loading-main { - font-weight: bold; -} - -.cmv-newProjectName { - padding: 5px; - padding-left: 20px; - padding-right: 20px; -} - -.cmv-gallery { - overflow-y: auto; - max-height: calc(100vh - 100px); - min-height: calc(100vh - 100px); -} - -.cmv-npnLabel { - padding-bottom: 4px; -} - -.cmv-search-area { - padding-left: 23px; - padding-top: 20px; - padding-bottom: 2px; -} diff --git a/app/src/UX/CodeMinecraftView.tsx b/app/src/UX/CodeMinecraftView.tsx deleted file mode 100644 index bd3e86c7..00000000 --- a/app/src/UX/CodeMinecraftView.tsx +++ /dev/null @@ -1,213 +0,0 @@ -import { Component, SyntheticEvent } from "react"; -import "./CodeMinecraftView.css"; -import { FormInput, InputProps, ThemeInput } from "@fluentui/react-northstar"; -import IAppProps from "./IAppProps"; -import { AppMode } from "./App"; -import Project from "../app/Project"; -import ProjectGallery, { GalleryProjectCommand } from "./ProjectGallery"; -import IGalleryProject from "../app/IGalleryProject"; -import IGallery from "../app/IGallery"; -import AppServiceProxy from "../core/AppServiceProxy"; -import Database from "../minecraft/Database"; -import Log from "../core/Log"; -import { ProjectTileDisplayMode } from "./ProjectTile"; - -enum CodeMinecraftViewMode { - gallery = 0, - addingProject = 1, -} - -interface ICodeMinecraftViewProps extends IAppProps { - project: Project | null; - theme: ThemeInput; - forceNewProject: boolean; - onModeChangeRequested?: (mode: AppMode) => void; - onProjectSelected?: (project: Project) => void; -} - -interface ICodeMinecraftViewState { - mode: CodeMinecraftViewMode; - loadingMessage: string | undefined; - additionalLoadingMessage: string | undefined; - gallery: IGallery | undefined; - newProjectName: string | undefined; - search: string | undefined; -} - -export default class CodeMinecraftView extends Component { - constructor(props: ICodeMinecraftViewProps) { - super(props); - - this._handleProjectGalleryCommand = this._handleProjectGalleryCommand.bind(this); - this._handleNewProjectName = this._handleNewProjectName.bind(this); - this._handleNewSearch = this._handleNewSearch.bind(this); - this._messageUpdater = this._messageUpdater.bind(this); - this._onGalleryLoaded = this._onGalleryLoaded.bind(this); - - if (this.props.carto.galleryLoaded) { - this.state = { - loadingMessage: undefined, - additionalLoadingMessage: undefined, - newProjectName: "MinecraftProject", - mode: CodeMinecraftViewMode.gallery, - gallery: this.props.carto.gallery, - search: undefined, - }; - } else { - this._loadGallery(); - } - } - - private async _loadGallery() { - this.props.carto.onGalleryLoaded.subscribe(this._onGalleryLoaded); - await this.props.carto.loadGallery(); - this._onGalleryLoaded(); - await Database.loadSnippets(); - this.forceUpdate(); - } - - private _onGalleryLoaded() { - this.setState({ - gallery: this.props.carto.gallery, - }); - } - - private async _messageUpdater(additionalMessage: string) { - let message = this.state.loadingMessage; - - if (!message) { - message = "Loading."; - } - - this.setState({ - mode: this.state.mode, - gallery: this.state.gallery, - loadingMessage: message, - additionalLoadingMessage: additionalMessage, - }); - } - - private async _handleProjectGalleryCommand(command: GalleryProjectCommand, project: IGalleryProject) { - switch (command) { - case GalleryProjectCommand.projectSelect: - case GalleryProjectCommand.newProject: - if (this.state.newProjectName !== undefined && this.state.newProjectName.length > 1) { - await AppServiceProxy.sendAsync( - "startNewProject", - JSON.stringify({ - name: this.state.newProjectName, - galleryProject: project, - }) - ); - - AppServiceProxy.sendAsync("closeAllStartPages", ""); - } else { - Log.message("Please specify a new project name."); - } - break; - } - } - - _handleNewSearch( - event: SyntheticEvent | React.KeyboardEvent | null, - data: (InputProps & { value: string }) | undefined - ) { - if (event === null || data === null || data === undefined || !this.state) { - return; - } - - const newSearch = data.value; - - this.setState({ - mode: this.state.mode, - loadingMessage: this.state.loadingMessage, - additionalLoadingMessage: this.state.additionalLoadingMessage, - gallery: this.state.gallery, - newProjectName: this.state.newProjectName, - search: newSearch, - }); - } - - _handleNewProjectName( - event: SyntheticEvent | React.KeyboardEvent | null, - data: (InputProps & { value: string }) | undefined - ) { - if (event === null || data === null || data === undefined || !this.state) { - return; - } - - const newMin = data.value; - - this.setState({ - loadingMessage: this.state.loadingMessage, - additionalLoadingMessage: this.state.additionalLoadingMessage, - newProjectName: newMin, - mode: this.state.mode, - gallery: this.props.carto.gallery, - }); - } - - render() { - if (!this.state || !this.state.gallery) { - return
Loading...
; - } - - let message = <>; - let additionalText = ""; - - let mainMessage = this.state.loadingMessage; - - if (this.props.forceNewProject && !mainMessage) { - mainMessage = "To start a new Minecraft project, set a name and select a Minecraft template."; - } - - if (this.state.additionalLoadingMessage) { - additionalText = this.state.additionalLoadingMessage; - } - - if (this.state.loadingMessage || this.props.forceNewProject) { - message = ( -
-
{mainMessage}
-
{additionalText}
-
- ); - } - - return ( -
- {message} -
-
New Project Name:
- -
-
- -
-
- -
-
- ); - } -} diff --git a/app/src/UX/CodeStartPage.css b/app/src/UX/CodeStartPage.css deleted file mode 100644 index 48a0c2cd..00000000 --- a/app/src/UX/CodeStartPage.css +++ /dev/null @@ -1,50 +0,0 @@ -.csp-outer { - min-width: 100%; - max-width: 100%; - min-height: 100vh; - max-height: 100vh; - display: grid; -} - -.csp-loading { - padding: 5px; - padding-left: 20px; - padding-right: 20px; -} - -.csp-loading-main { - font-weight: bold; -} - -.csp-newProjectName { - padding: 5px; - padding-left: 20px; - grid-column: 1; - padding-right: 20px; -} - -.csp-gallery { - overflow-y: auto; - max-height: calc(100vh - 100px); - min-height: calc(100vh - 100px); -} - -.csp-projectDetails { - grid-template-columns: 250px 1fr; - display: grid; -} - -.csp-goButtonArea { - grid-column: 2; - padding-top: 28px; -} - -.csp-npnLabel { - padding-bottom: 4px; -} - -.csp-search-area { - padding-left: 20px; - padding-top: 20px; - padding-bottom: 2px; -} diff --git a/app/src/UX/CodeStartPage.tsx b/app/src/UX/CodeStartPage.tsx deleted file mode 100644 index 7f4e4000..00000000 --- a/app/src/UX/CodeStartPage.tsx +++ /dev/null @@ -1,236 +0,0 @@ -import { Component, SyntheticEvent } from "react"; -import "./CodeStartPage.css"; -import { Button, FormInput, InputProps, ThemeInput } from "@fluentui/react-northstar"; -import IAppProps from "./IAppProps"; -import { AppMode } from "./App"; -import Project from "./../app/Project"; -import ProjectGallery, { GalleryProjectCommand } from "./ProjectGallery"; -import IGalleryProject from "../app/IGalleryProject"; -import IGallery from "../app/IGallery"; -import AppServiceProxy from "../core/AppServiceProxy"; -import Database from "../minecraft/Database"; -import Log from "../core/Log"; -import { ProjectTileDisplayMode } from "./ProjectTile"; - -enum CodeStartPageMode { - gallery = 0, - addingProject = 1, -} - -interface ICodeStartPageProps extends IAppProps { - project: Project | null; - theme: ThemeInput; - forceNewProject: boolean; - onModeChangeRequested?: (mode: AppMode) => void; - onProjectSelected?: (project: Project) => void; -} - -interface ICodeStartPageState { - mode: CodeStartPageMode; - loadingMessage: string | undefined; - additionalLoadingMessage: string | undefined; - gallery: IGallery | undefined; - newProjectName: string | undefined; - newProject: IGalleryProject | undefined; - search: string | undefined; -} - -export default class CodeStartPage extends Component { - constructor(props: ICodeStartPageProps) { - super(props); - - this._handleProjectGalleryCommand = this._handleProjectGalleryCommand.bind(this); - this._handleNewProjectName = this._handleNewProjectName.bind(this); - this._handleNewSearch = this._handleNewSearch.bind(this); - this._messageUpdater = this._messageUpdater.bind(this); - this._onGalleryLoaded = this._onGalleryLoaded.bind(this); - this._createProject = this._createProject.bind(this); - - if (this.props.carto.galleryLoaded) { - this.state = { - loadingMessage: undefined, - additionalLoadingMessage: undefined, - newProjectName: "MinecraftProject", - newProject: undefined, - mode: CodeStartPageMode.gallery, - gallery: this.props.carto.gallery, - search: undefined, - }; - } else { - this._loadGallery(); - } - } - - private async _loadGallery() { - this.props.carto.onGalleryLoaded.subscribe(this._onGalleryLoaded); - await this.props.carto.loadGallery(); - this._onGalleryLoaded(); - await Database.loadSnippets(); - this.forceUpdate(); - } - - private _onGalleryLoaded() { - this.setState({ - gallery: this.props.carto.gallery, - }); - } - - private async _messageUpdater(additionalMessage: string) { - let message = this.state.loadingMessage; - - if (!message) { - message = "Loading."; - } - - this.setState({ - mode: this.state.mode, - gallery: this.state.gallery, - loadingMessage: message, - additionalLoadingMessage: additionalMessage, - }); - } - - private async _handleProjectGalleryCommand(command: GalleryProjectCommand, project: IGalleryProject) { - switch (command) { - case GalleryProjectCommand.projectSelect: - case GalleryProjectCommand.newProject: - this.setState({ - loadingMessage: this.state.loadingMessage, - additionalLoadingMessage: this.state.additionalLoadingMessage, - newProjectName: this.state.newProjectName, - newProject: project, - mode: this.state.mode, - gallery: this.props.carto.gallery, - }); - - break; - } - } - - _handleNewSearch( - event: SyntheticEvent | React.KeyboardEvent | null, - data: (InputProps & { value: string }) | undefined - ) { - if (event === null || data === null || data === undefined || !this.state) { - return; - } - - const newSearch = data.value; - - this.setState({ - mode: this.state.mode, - loadingMessage: this.state.loadingMessage, - additionalLoadingMessage: this.state.additionalLoadingMessage, - newProject: this.state.newProject, - gallery: this.state.gallery, - newProjectName: this.state.newProjectName, - search: newSearch, - }); - } - - _handleNewProjectName( - event: SyntheticEvent | React.KeyboardEvent | null, - data: (InputProps & { value: string }) | undefined - ) { - if (event === null || data === null || data === undefined || !this.state) { - return; - } - - const newMin = data.value; - - this.setState({ - loadingMessage: this.state.loadingMessage, - additionalLoadingMessage: this.state.additionalLoadingMessage, - newProjectName: newMin, - newProject: this.state.newProject, - mode: this.state.mode, - gallery: this.props.carto.gallery, - }); - } - - async _createProject() { - if (this.state.newProjectName !== undefined && this.state.newProjectName.length > 1) { - await AppServiceProxy.sendAsync( - "startNewProject", - JSON.stringify({ - name: this.state.newProjectName, - galleryProject: this.state.newProject, - }) - ); - - AppServiceProxy.sendAsync("closeAllStartPages", ""); - } else { - Log.message("Please specify a new project name."); - } - } - - render() { - if (!this.state || !this.state.gallery) { - return
Loading...
; - } - - let message = <>; - let additionalText = ""; - - let mainMessage = this.state.loadingMessage; - - if (this.props.forceNewProject && !mainMessage) { - mainMessage = "To start a new Minecraft project, set a name and select a Minecraft template."; - } - - if (this.state.additionalLoadingMessage) { - additionalText = this.state.additionalLoadingMessage; - } - - if (this.state.loadingMessage || this.props.forceNewProject) { - message = ( -
-
{mainMessage}
-
{additionalText}
-
- ); - } - - return ( -
- {message} -
-
-
New Project Name:
- -
-
- -
-
-
- -
-
- -
-
- ); - } -} diff --git a/app/src/UX/CodeToolbox.css b/app/src/UX/CodeToolbox.css deleted file mode 100644 index eda320fe..00000000 --- a/app/src/UX/CodeToolbox.css +++ /dev/null @@ -1,88 +0,0 @@ -.ct-outer { - min-width: 100%; - max-width: 100%; - min-height: 100vh; - max-height: 100vh; - display: grid; -} - -.ct-area { - min-width: 100vw; - max-width: 100vw; - min-height: 100vh; - max-height: 100vh; - grid-column: 1; - grid-row: 1; - margin-left: 0px; - margin-top: 0px; - text-align: center; - vertical-align: middle; -} - -.ct-selectedProject { - padding-top: 20px; - padding-left: 30px; -} - -.ct-optionsGrid { - display: grid; - height: 330px; -} - -.ct-type-label { - grid-row: 1; - grid-column: 1; - user-select: none; -} - -.ct-type-options { - padding-bottom: 18px; -} - -.ct-import-label { - grid-row: 2; - grid-column: 1; - padding-top: 7px; - user-select: none; -} - -.ct-import-input { - grid-row: 2; - grid-column: 2; - text-align: left; - padding-bottom: 8px; -} - -.ct-export-label { - grid-row: 3; - grid-column: 1; - padding-top: 7px; - user-select: none; -} - -.ct-export-input { - grid-row: 3; - grid-column: 2; - text-align: left; - padding-bottom: 8px; -} - -.ct-buttonArea { - text-align: right; - padding: 10px; -} - -.ct-buttonArea button { - margin-left: 10px; -} - -.ct-actionsToolBarArea { - padding-left: 24px; -} -.ct-actionsToolBarArea .ui-toolbar__itemicon { - color: green !important; -} - -.ct-settingsArea { - padding-left: 0px; -} diff --git a/app/src/UX/CodeToolbox.tsx b/app/src/UX/CodeToolbox.tsx deleted file mode 100644 index 4a6fb710..00000000 --- a/app/src/UX/CodeToolbox.tsx +++ /dev/null @@ -1,84 +0,0 @@ -import { Component } from "react"; -import "./CodeToolbox.css"; -import { ThemeInput } from "@fluentui/react-northstar"; -import IAppProps from "./IAppProps"; -import { AppMode } from "./App"; -import Project from "./../app/Project"; -import ProjectEditor from "./ProjectEditor"; -import { CartoEditorViewMode } from "../app/ICartoData"; -import ProjectItem from "../app/ProjectItem"; -import AppServiceProxy from "../core/AppServiceProxy"; -import MessageProxyStorage from "../vscodeweb/MessageProxyStorage"; -import Utilities from "../core/Utilities"; - -interface ICodeToolboxProps extends IAppProps { - project: Project | null; - theme: ThemeInput; - onModeChangeRequested?: (mode: AppMode) => void; - onProjectSelected?: (project: Project) => void; -} - -interface ICodeToolboxState { - mode: CodeToolboxMode; -} - -export enum CodeToolboxMode { - configuring = 0, - executing = 1, - done = 2, -} - -export default class CodeToolbox extends Component { - constructor(props: ICodeToolboxProps) { - super(props); - - this._handleProjectItemSelected = this._handleProjectItemSelected.bind(this); - - this.state = { - mode: CodeToolboxMode.configuring, - }; - } - - private async _handleProjectItemSelected(newProjectItem: ProjectItem, forceRawView: boolean) { - if (!newProjectItem.file) { - return; - } - - let path = newProjectItem.file.fullPath; - - path = path.replace(/\\/gi, "/"); - - const storage = newProjectItem.file.parentFolder.storage; - - if (storage instanceof MessageProxyStorage) { - path = Utilities.ensureEndsWithSlash(storage.channelId) + Utilities.ensureNotStartsWithSlash(path); - } - - AppServiceProxy.sendAsync( - "openItem", - JSON.stringify({ - path: path, - }) - ); - } - - render() { - let interior = <>; - - if (this.props.project) { - interior = ( - - ); - } - - return
{interior}
; - } -} diff --git a/app/src/UX/CodeToolboxLanding.css b/app/src/UX/CodeToolboxLanding.css deleted file mode 100644 index d8bc02f8..00000000 --- a/app/src/UX/CodeToolboxLanding.css +++ /dev/null @@ -1,21 +0,0 @@ -.ctl-outer { - min-width: 100%; - max-width: 100%; -} - -.ctl-newButtonArea { - padding-top: 24px; - text-align: center; -} - -.ctl-logo { - width: 128px; - height: 128px; - image-rendering: pixelated; -} - -.ctl-logoArea { - text-align: center; - padding-top: 30px; - padding-bottom: 10px; -} diff --git a/app/src/UX/CodeToolboxLanding.tsx b/app/src/UX/CodeToolboxLanding.tsx deleted file mode 100644 index aa4e1a00..00000000 --- a/app/src/UX/CodeToolboxLanding.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { Component } from "react"; -import "./CodeToolboxLanding.css"; -import { Button, ThemeInput } from "@fluentui/react-northstar"; -import IAppProps from "./IAppProps"; -import Project from "./../app/Project"; -import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; -import AppServiceProxy from "../core/AppServiceProxy"; -import { faFile } from "@fortawesome/free-regular-svg-icons"; -import { AppMode } from "./App"; -import CartoApp from "../app/CartoApp"; - -interface ICodeToolboxLandingProps extends IAppProps { - project: Project | null; - theme: ThemeInput; - forceNewProject: boolean; - onModeChangeRequested?: (mode: AppMode) => void; -} - -interface ICodeToolboxLandingState { - mode: CodeToolboxLandingMode; -} - -export enum CodeToolboxLandingMode { - configuring = 0, - executing = 1, - done = 2, -} - -export default class CodeToolboxLanding extends Component { - constructor(props: ICodeToolboxLandingProps) { - super(props); - - this._handleNewProjectClick = this._handleNewProjectClick.bind(this); - } - - _handleNewProjectClick() { - AppServiceProxy.sendAsync("showNewProjectPage", ""); - } - - render() { - const imageLogo = ( - logo - ); - - return ( -
-
-
{imageLogo}
-
-
- ); - } -} diff --git a/app/src/UX/JsonEditor.tsx b/app/src/UX/JsonEditor.tsx index f35929b7..e2c03e7f 100644 --- a/app/src/UX/JsonEditor.tsx +++ b/app/src/UX/JsonEditor.tsx @@ -124,7 +124,7 @@ export default class JsonEditor extends Component{itemList}; - } else if (viewMode === CartoEditorViewMode.codeLanding) { - column2 = ( -
- -
- ); } else if (viewMode === CartoEditorViewMode.toolboxFocus) { column2 = (
diff --git a/app/src/UX/ProjectItemList.css b/app/src/UX/ProjectItemList.css index 845cba78..1bc84a90 100644 --- a/app/src/UX/ProjectItemList.css +++ b/app/src/UX/ProjectItemList.css @@ -64,6 +64,7 @@ padding-bottom: 0px; margin-bottom: 0px; grid-template-columns: 244px 38px; + font-size: 0.875rem; } .pil-itemLabel { diff --git a/app/src/UX/ProjectItemList.tsx b/app/src/UX/ProjectItemList.tsx index 2b67e348..2ff3ea3d 100644 --- a/app/src/UX/ProjectItemList.tsx +++ b/app/src/UX/ProjectItemList.tsx @@ -1176,18 +1176,6 @@ export default class ProjectItemList extends Component(); - private _gameStateManager: GameStateManager; - - private _nextPollInterval = 500; - private _pollIntervalCount = 0; - - errorStatus?: CartoMinecraftErrorStatus; - errorMessage?: string; - - worldFolder: IFolder | undefined; - projectFolder: IFolder | undefined; - - private messagesReceived: { [received: number]: IMinecraftMessage } = {}; - - private _onWorldStorageReady = new EventDispatcher(); - private _onProjectStorageReady = new EventDispatcher(); - private _onMessage = new EventDispatcher(); - - public get onWorldFolderReady() { - return this._onWorldStorageReady.asEvent(); - } - - public get onProjectFolderReady() { - return this._onProjectStorageReady.asEvent(); - } - - public get onMessage() { - return this._onMessage.asEvent(); - } - - get canDeployFiles() { - return true; - } - - get activeProject() { - return this._project; - } - - set activeProject(newProject: Project | undefined) { - this._project = newProject; - } - - public get gameStateManager() { - return this._gameStateManager; - } - - public get onStateChanged() { - return this._onStateChanged.asEvent(); - } - - public get onRefreshed() { - return this._onStateChanged.asEvent(); - } - - canPrepare() { - return true; - } - - constructor(carto: Carto) { - this._carto = carto; - this.state = CartoMinecraftState.none; - this._gameStateManager = new GameStateManager(this._carto); - - this.doHeartbeat = this.doHeartbeat.bind(this); - } - - async updateStatus() { - return this.state; - } - - setState(newState: CartoMinecraftState) { - if (this.state === newState) { - return; - } - - this.state = newState; - this._onStateChanged.dispatch(this, this.state); - } - - processExternalMessage(command: string, data: string): void { - switch (command.toLowerCase()) { - case "wsevent": - try { - const eventObj = JSON.parse(data); - this._gameStateManager.handleEvent(eventObj); - } catch (e) {} - break; - } - } - - async prepare(force?: boolean) {} - - async prepareAndStart(push: MinecraftPush): Promise { - if (!push.project || !this._carto.remoteServerAuthToken) { - Log.throwUnexpectedUndefined("PAS"); - return { - type: PrepareAndStartResultType.error, - }; - } - - this.setState(CartoMinecraftState.preparing); - - await push.project.updateAutogeneratedItems(); - - const zipStorage = new ZipStorage(); - - //await StorageUtilities.syncFolderTo(carto.deploymentStorage.rootFolder, zipStorage.rootFolder, true, true, false); - - const zipBehaviorPackFolder = await zipStorage.rootFolder.ensureFolder("development_behavior_packs"); - - await ProjectTools.deployToBehaviorPackFolder(push.project, zipBehaviorPackFolder); - - await zipStorage.rootFolder.saveAll(); - - // consider doing a diff from the last push. - if (this._lastFullPush) { - const differenceSet = await StorageUtilities.getDifferences( - this._lastFullPush.rootFolder, - zipStorage.rootFolder, - true - ); - - this._lastFullPush = zipStorage; - - // we don't have to do anything here. (may need a force flag here at some point) - if (differenceSet.fileDifferences.length === 0 && differenceSet.folderDifferences.length === 0) { - Log.message("No changes detected in this update. No push is being made."); - return { - type: PrepareAndStartResultType.error, - }; - } - - if (!differenceSet.getHasDeletions()) { - const diffUpdate = new ZipStorage(); - - await differenceSet.copyFileUpdatesAndAdds(diffUpdate); - await diffUpdate.rootFolder.saveAll(); - - const diffBinary = await diffUpdate.generateBlobAsync(); - - this._carto.notifyStatusUpdate("Uploading changed files to " + this._carto.fullRemoteServerUrl); - - const isReloadable = MinecraftUtilities.isReloadableSetOfChanges(differenceSet); - - await axios({ - method: "patch", - url: this.getBaseApiUrl() + "upload/", //API url - headers: { - Authorization: "Bearer mctauth=" + this._carto.remoteServerAuthToken, - "Content-Type": "application/zip", - "mcttools-reloadable": isReloadable, - }, - data: diffBinary, // Buffer - maxContentLength: Infinity, - maxBodyLength: Infinity, - }); - - this._carto.notifyStatusUpdate("Upload complete"); - return { - type: PrepareAndStartResultType.started, - }; - } - } - - this._carto.notifyStatusUpdate("Files created in zip. Packaging"); - - const zipBinary = await zipStorage.generateBlobAsync(); - - this._lastFullPush = zipStorage; - - this._carto.notifyStatusUpdate("Uploading to " + this._carto.fullRemoteServerUrl); - - await axios({ - method: "post", - url: this.getBaseApiUrl() + "upload/", //API url - headers: { - Authorization: "Bearer mctauth=" + this._carto.remoteServerAuthToken, - "Content-Type": "application/zip", - }, - data: zipBinary, // Buffer - maxContentLength: Infinity, - maxBodyLength: Infinity, - }); - - this.setState(CartoMinecraftState.prepared); - - this._carto.notifyStatusUpdate("Upload complete"); - - return { - type: PrepareAndStartResultType.started, - }; - } - - async runCommand(command: string) { - if (!this._carto.remoteServerAuthToken) { - Log.throwUnexpectedUndefined("RC"); - return; - } - - this.resetInterval(); - - const result = await axios({ - method: "post", - url: this.getBaseApiUrl() + "command/", //API url - headers: { - Authorization: "Bearer mctauth=" + this._carto.remoteServerAuthToken, - }, - data: command, - maxContentLength: Infinity, - maxBodyLength: Infinity, - }); - - return result.data as string; - } - - getBaseApiUrl(): string { - if (!this._carto.fullRemoteServerUrl) { - Log.throwUnexpectedUndefined("GBAU"); - return ""; - } - - let port = this._carto.remoteServerPort; - - if (!port) { - port = 0; - } - - return StorageUtilities.ensureEndsWithDelimiter(this._carto.fullRemoteServerUrl) + "api/" + port + "/"; - } - - async initSession(slot: number) {} - - async deploy() {} - - async stop() {} - - processServerStatus(newStatus: CartoServerStatus) { - let wasActive = false; - if (newStatus.status) { - switch (newStatus.status) { - case DedicatedServerStatus.deploying: - if (this.state !== CartoMinecraftState.preparing) { - this.setState(CartoMinecraftState.preparing); - wasActive = true; - } - break; - case DedicatedServerStatus.launching: - if (this.state !== CartoMinecraftState.starting) { - this.setState(CartoMinecraftState.starting); - wasActive = true; - } - break; - case DedicatedServerStatus.starting: - if (this.state !== CartoMinecraftState.starting) { - this.setState(CartoMinecraftState.starting); - wasActive = true; - } - break; - case DedicatedServerStatus.started: - if (this.state !== CartoMinecraftState.started) { - this.setState(CartoMinecraftState.started); - - if (!this._carto.successfullyConnectedToRemoteMinecraft) { - this._carto.successfullyConnectedToRemoteMinecraft = true; - this._carto.save(); - } - - wasActive = true; - } - break; - case DedicatedServerStatus.stopped: - if (this.state !== CartoMinecraftState.stopped) { - this.setState(CartoMinecraftState.stopped); - wasActive = true; - } - break; - } - } - - if (newStatus.recentMessages) { - for (const recentMessage of newStatus.recentMessages) { - if (!this.messagesReceived[recentMessage.received]) { - this.messagesReceived[recentMessage.received] = recentMessage; - - this._carto.notifyStatusUpdate(recentMessage.message); - - this._onMessage.dispatch(this, recentMessage); - } - } - } - - return wasActive; - } - - resetInterval() { - this._nextPollInterval = 100; - this._pollIntervalCount = 0; - } - - async doHeartbeat() { - let wasActive = false; - - try { - const result = await axios({ - method: "get", - url: this.getBaseApiUrl() + "status/", //API url - headers: { - Authorization: "Bearer mctauth=" + this._carto.remoteServerAuthToken, - }, - }); - - const obj = result.data as CartoServerStatus; - - if (obj) { - wasActive = this.processServerStatus(obj); - } - } catch (e) { - this.errorMessage = "Disconnected from server"; - this.setState(CartoMinecraftState.disconnected); - return; - } - - if (this._nextPollInterval >= 0) { - if (wasActive) { - this._nextPollInterval = 100; - this._pollIntervalCount = 0; - } else { - this._pollIntervalCount++; - - // back off our polling if nothing interesting is happening - if (this._pollIntervalCount === 50 && this._nextPollInterval < 500) { - this._nextPollInterval = 500; - this._pollIntervalCount = 0; - } else if (this._pollIntervalCount === 50 && this._nextPollInterval === 500) { - this._nextPollInterval = 5000; - this._pollIntervalCount = 0; - } - } - - // @ts-ignore - window.setTimeout(this.doHeartbeat, this._nextPollInterval); - } - } - - async initialize() { - const url = this._carto.fullRemoteServerUrl; - this._nextPollInterval = -1; - - if ( - this.state === CartoMinecraftState.initialized || - this.state === CartoMinecraftState.preparing || - this.state === CartoMinecraftState.prepared || - this.state === CartoMinecraftState.starting || - this.state === CartoMinecraftState.started - ) { - return; - } - - this.setState(CartoMinecraftState.initialized); - - if (!this._carto || !url || !this._carto.remoteServerPasscode) { - this.errorMessage = "Not fully configured."; - this.errorStatus = CartoMinecraftErrorStatus.configuration; - return; - } - - let authReq: AxiosResponse | undefined = undefined; - - try { - authReq = await axios.post(url + "api/auth/", "passcode=" + this._carto.remoteServerPasscode); - - if (authReq === undefined) { - this.errorMessage = "Could not connect to server."; - this.errorStatus = CartoMinecraftErrorStatus.loginFailed; - this.setState(CartoMinecraftState.error); - return; - } - - if (authReq.status !== 200) { - this.errorMessage = "Login failed."; - this.errorStatus = CartoMinecraftErrorStatus.loginFailed; - this.setState(CartoMinecraftState.error); - return; - } - - let result: CartoServerAuthenticationResult | undefined = undefined; - - if (typeof authReq.data === "string") { - result = JSON.parse(authReq.data); - } else if (typeof authReq.data === "object") { - result = authReq.data; - } - - if (result === undefined) { - this.errorMessage = "Unexpected server error."; - this.errorStatus = CartoMinecraftErrorStatus.serverError; - this.setState(CartoMinecraftState.error); - - return; - } - - this.setState(CartoMinecraftState.initialized); - - this._carto.remoteServerAuthToken = result.token + "|" + result.iv; - this._carto.remoteServerAccessLevel = result.permissionLevel; - - const desiredPort = this._carto.remoteServerPort; - - if ( - desiredPort !== undefined && - desiredPort >= 0 && - desiredPort <= 3 && - result.serverStatus.length > desiredPort - ) { - const status = result.serverStatus[desiredPort]; - this.processServerStatus(status); - } - - await this._carto.save(); - this._nextPollInterval = 500; - - // @ts-ignore - window.setTimeout(this.doHeartbeat, this._nextPollInterval); - } catch (e: any) { - this.errorMessage = e.toString(); - - if (this.errorMessage && this.errorMessage.indexOf("401") >= 0) { - this.errorStatus = CartoMinecraftErrorStatus.loginFailed; - this.setState(CartoMinecraftState.error); - } else { - this.errorStatus = CartoMinecraftErrorStatus.serverUnavailable; - this.setState(CartoMinecraftState.error); - } - } - } -} diff --git a/app/src/autoscript/AutoScript.ts b/app/src/autoscript/AutoScript.ts deleted file mode 100644 index 604b9056..00000000 --- a/app/src/autoscript/AutoScript.ts +++ /dev/null @@ -1,165 +0,0 @@ -import IAutoScriptData from "./IAutoScriptData.js"; -import AutoScriptGroup from "./AutoScriptGroup"; -import Test from "../gameTest/Test"; -import Location from "./../minecraft/Location"; -import BlockLocation from "./../minecraft/BlockLocation"; -import AutoScriptAction from "./AutoScriptAction"; -import Utilities from "../core/Utilities"; - -export const AUTOGENERATED_WHOLEFILE_JS_SEPARATOR = - "// ===== AUTOGENERATED FILE ===== CONTENT WITHIN THIS FILE WILL BE WIPED AND UPDATED WHEN USED IN TOOLING"; - -export const AUTOGENERATED_WHOLEFILE_MCFUNCTION_SEPARATOR = - "# ===== AUTOGENERATED FILE ===== CONTENT WITHIN THIS FILE WILL BE WIPED AND UPDATED WHEN USED IN TOOLING"; - -export default class AutoScript extends AutoScriptGroup { - scriptData: IAutoScriptData; - _test: Test | undefined; - _locationRoot: Location | undefined; - - get locationRoot() { - return this._locationRoot; - } - - set locationRoot(newRoot: Location | undefined) { - this._locationRoot = newRoot; - } - - absolutizeLocation(location: Location) { - if (!this.locationRoot) { - return location; - } - - return new Location( - this.locationRoot.x + location.x, - this.locationRoot.y + location.y, - this.locationRoot.z + location.z - ); - } - - absolutizeBlockLocation(location: BlockLocation) { - if (!this.locationRoot) { - return location; - } - - return new BlockLocation( - Math.round(this.locationRoot.x + location.x), - Math.round(this.locationRoot.y + location.y), - Math.round(this.locationRoot.z + location.z) - ); - } - - relativizeLocation(location: Location) { - if (!this.locationRoot) { - return location; - } - - return new Location( - location.x - this.locationRoot.x, - location.y - this.locationRoot.y, - location.z - this.locationRoot.z - ); - } - - relativizeBlockLocation(location: BlockLocation) { - if (!this.locationRoot) { - return location; - } - - return new BlockLocation( - Math.round(location.x - this.locationRoot.x), - Math.round(location.y - this.locationRoot.y), - Math.round(location.z - this.locationRoot.z) - ); - } - - addAction(action: AutoScriptAction) { - this.actions.push(action); - } - get test() { - return this._test; - } - - get name() { - return this.scriptData.name; - } - - set name(newValue: string) { - this.scriptData.name = newValue; - } - - constructor(data: IAutoScriptData) { - super(data); - this.scriptData = data; - this.script = this; - } - - generateJavaScript(): string { - const lines: string[] = []; - - this.addJavaScriptLines(lines); - - return lines.join("\n"); - } - - generateMCFunction() { - const lines = this.generateCommandLines(); - - return AUTOGENERATED_WHOLEFILE_MCFUNCTION_SEPARATOR + "\n" + lines.join("\n"); - } - - generateCommandLines(): string[] { - const lines: string[] = []; - - this.addCommandLines(lines); - - return lines; - } - - generateGameTestJavaScript(groupName: string, nameSuffix: string, structureName: string) { - const lines: string[] = []; - - let name = this.name; - - if (nameSuffix) { - name += nameSuffix; - } - - name = Utilities.getSimpleString(name); - groupName = Utilities.getSimpleString(groupName); - - lines.push("async function gt_" + name + "(test) {"); - this.addJavaScriptGroupLines(lines, 2, { - isFunction: true, - addTestIdlePause: true, - useGameTestApis: true, - }); - lines.push("}"); - lines.push( - 'registerAsync("' + - groupName + - '", "' + - name + - '", gt_' + - name + - ').maxTicks(4000).structureName("gametest:' + - structureName + - 'empty");' - ); - - return lines.join("\r\n"); - } - - addJavaScriptLines(lines: string[]) { - lines.push(AUTOGENERATED_WHOLEFILE_JS_SEPARATOR); - lines.push("export default function " + this.name + "() {"); - this.addJavaScriptGroupLines(lines, 2, { - isFunction: true, - }); - lines.push("}"); - } - - addCommandLines(lines: string[]) { - this.addCommandGroupLines(lines, 0, {}); - } -} diff --git a/app/src/autoscript/AutoScriptAction.ts b/app/src/autoscript/AutoScriptAction.ts deleted file mode 100644 index c5b69014..00000000 --- a/app/src/autoscript/AutoScriptAction.ts +++ /dev/null @@ -1,233 +0,0 @@ -import AutoScript from "./AutoScript.js"; -import AutoScriptGroup from "./AutoScriptGroup.js"; -import IAutoScriptAction from "./IAutoScriptAction.js"; -import Location from "./../minecraft/Location"; -import BlockLocation from "./../minecraft/BlockLocation"; -import IScriptOptions from "./IScriptOptions.js"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import ICommandRequirements from "./ICommandRequirements.js"; -import { EventDispatcher } from "ste-events"; -import IGetSetPropertyObject from "../dataform/IGetSetPropertyObject.js"; -import AutoScriptScope from "./AutoScriptScope.js"; - -export enum AutoScriptActionType { - simulatedPlayerSpawn = "simulatedplayer.spawn", - simulatedPlayerMove = "simulatedplayer.move", - simulatedPlayerInteract = "simulatedplayer.interact", - spawnEntity = "entity.spawn", - idle = "idle", -} - -export default abstract class AutoScriptAction implements IGetSetPropertyObject { - data: IAutoScriptAction; - group: AutoScriptGroup; - script: AutoScript; - - private _onPropertyChanged = new EventDispatcher(); - - public get onPropertyChanged() { - return this._onPropertyChanged.asEvent(); - } - - get shortSubjectId() { - return "obj"; - } - - get withId() { - const withId = this.data.withId; - - if (withId) { - return withId; - } - - return this.shortSubjectId; - } - - get setId() { - const setId = this.data.setId; - - if (setId) { - return setId; - } - - return this.shortSubjectId; - } - - abstract get typeTitle(): string; - abstract get title(): string; - - get type(): string { - return this.data.type; - } - - constructor(group: AutoScriptGroup, data: IAutoScriptAction) { - this.group = group; - - if (!this.group.script) { - throw new Error("Cannot add action to unattached group"); - } - - this.script = this.group.script; - - this.data = data; - } - - abstract validate(): boolean; - - run(scope: AutoScriptScope) {} - - getProperty(id: string) { - return (this.data as any)[id] as any; - } - - setProperty(id: string, value: any) { - (this.data as any)[id] = value; - } - - getArgumentAsLocation(name: string) { - const val = (this.data as any)[name]; - - if (val instanceof Array && val.length >= 3) { - const loc = new Location(val[0], val[1], val[2]); - - return loc; - } - - return undefined; - } - - getArgumentAsBlockLocation(name: string) { - const val = (this.data as any)[name]; - - if (val instanceof Array && val.length >= 3) { - const loc = new BlockLocation(val[0], val[1], val[2]); - - return loc; - } - - return undefined; - } - - _notifyPropertyChanged(propertyName: string) { - this._onPropertyChanged.dispatch(this, propertyName); - } - - abstract getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements; - abstract getCommandRequirements(options: ICommandOptions): ICommandRequirements; - abstract addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions): void; - abstract addCommandLines(lines: string[], indent: number, options: ICommandOptions): void; - - getScriptTest() { - return "test"; - } - - getScriptWith() { - if (!this.data.withId) { - return "obj"; - } - - return this.data.withId; - } - - getScriptSet() { - if (!this.data.setId) { - return "obj"; - } - - return this.data.setId; - } - - getCommandWith() { - if (!this.data.withId) { - return "obj"; - } - - return this.data.withId; - } - - getCommandSet() { - if (!this.data.setId) { - return "obj"; - } - - return this.data.setId; - } - - getArgumentAsNumber(name: string) { - const val = (this.data as any)[name]; - - if (typeof val === "number") { - return val; - } else if (typeof val === "string") { - return parseFloat(val); - } - - throw new Error(); - } - - getArgumentAsString(name: string) { - const val = (this.data as any)[name]; - - return val; - } - - validateArgumentIsEntityType(name: string) { - const val = (this.data as any)[name]; - - if (!val || typeof val !== "string") { - throw new Error("Argument '" + name + "' is not defined."); - } - - return true; - } - - absolutizeLocation(location: Location) { - if (!this.script.locationRoot) { - return location; - } - - return new Location( - this.script.locationRoot.x + location.x, - this.script.locationRoot.y + location.y, - this.script.locationRoot.z + location.z - ); - } - - absolutizeBlockLocation(location: BlockLocation) { - if (!this.script.locationRoot) { - return location; - } - - return new BlockLocation( - Math.round(this.script.locationRoot.x + location.x), - Math.round(this.script.locationRoot.y + location.y), - Math.round(this.script.locationRoot.z + location.z) - ); - } - - validateArgumentIsType(name: string, type: string) { - const val = (this.data as any)[name]; - - const typestr = typeof val; - - switch (type) { - case "BlockLocation": - case "Location": - if (!(val instanceof Array) || val.length !== 3) { - throw new Error("Expected an array of 3 numbers for parameter '" + name + "'"); - } - break; - - case "boolean": - case "number": - case "string": - if (typestr !== type) { - throw new Error("Unexpected type mismatch: " + name + " is " + typestr + " (expected " + type + ")"); - } - break; - } - - return true; - } -} diff --git a/app/src/autoscript/AutoScriptError.ts b/app/src/autoscript/AutoScriptError.ts deleted file mode 100644 index 6010b139..00000000 --- a/app/src/autoscript/AutoScriptError.ts +++ /dev/null @@ -1,11 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; - -export default class AutoScriptError { - action: AutoScriptAction; - message: string; - - constructor(action: AutoScriptAction, message: string) { - this.action = action; - this.message = message; - } -} diff --git a/app/src/autoscript/AutoScriptGroup.ts b/app/src/autoscript/AutoScriptGroup.ts deleted file mode 100644 index 712bf446..00000000 --- a/app/src/autoscript/AutoScriptGroup.ts +++ /dev/null @@ -1,219 +0,0 @@ -import AutoScript from "./AutoScript"; -import AutoScriptAction from "./AutoScriptAction"; -import EntitySpawnAction from "./EntitySpawnAction"; -import SimulatedPlayerMoveAction from "./SimulatedPlayerMoveAction"; -import IAutoScriptAction from "./IAutoScriptAction"; -import IAutoScriptGroup from "./IAutoScriptGroup"; -import SimulatedPlayerSpawnAction from "./SimulatedPlayerSpawnAction"; -import IdleAction from "./IdleAction"; -import IScriptOptions from "./IScriptOptions"; -import ICommandOptions from "./ICommandOptions"; -import IScriptRequirements from "./IScriptRequirements"; -import ICommandRequirements from "./ICommandRequirements"; -import Test from "../gameTest/Test"; -import AutoScriptScope from "./AutoScriptScope"; - -import Location from "../minecraft/Location"; -import BlockLocation from "../minecraft/BlockLocation"; -import IWorld from "../minecraft/IWorld"; - -export default class AutoScriptGroup { - data: IAutoScriptGroup; - script?: AutoScript; - actions: AutoScriptAction[]; - - constructor(data: IAutoScriptGroup) { - this.data = data; - this.actions = []; - } - - run(world?: IWorld, test?: Test, parentScope?: AutoScriptScope) { - const scope = new AutoScriptScope(); - - scope.parent = parentScope; - scope.test = test; - scope.world = world; - - for (let i = 0; i < this.actions.length; i++) { - const action = this.actions[i]; - - action.run(scope); - } - } - - absolutizeLocation(location: Location) { - if (!this.script || !this.script.locationRoot) { - return location; - } - - return new Location( - this.script.locationRoot.x + location.x, - this.script.locationRoot.y + location.y, - this.script.locationRoot.z + location.z - ); - } - - absolutizeBlockLocation(location: BlockLocation) { - if (!this.script || !this.script.locationRoot) { - return location; - } - - return new BlockLocation( - Math.round(this.script.locationRoot.x + location.x), - Math.round(this.script.locationRoot.y + location.y), - Math.round(this.script.locationRoot.z + location.z) - ); - } - - relativizeLocation(location: Location) { - if (!this.script || !this.script.locationRoot) { - return location; - } - - return new Location( - location.x - this.script.locationRoot.x, - location.y - this.script.locationRoot.y, - location.z - this.script.locationRoot.z - ); - } - - relativizeBlockLocation(location: BlockLocation) { - if (!this.script || !this.script.locationRoot) { - return location; - } - - return new BlockLocation( - Math.round(location.x - this.script.locationRoot.x), - Math.round(location.y - this.script.locationRoot.y), - Math.round(location.z - this.script.locationRoot.z) - ); - } - - addAction(action: AutoScriptAction) { - this.actions.push(action); - } - - addJavaScriptGroupLines(lines: string[], indent: number, options: IScriptOptions) { - const req: IScriptRequirements = {}; - - for (const action of this.actions) { - AutoScriptGroup.mergeScriptRequirements(req, action.getJavaScriptRequirements(options)); - } - - if (req.needsLocalOverworld) { - AutoScriptGroup.addLine(lines, indent, 'const overworld = world.getDimension("overworld");'); - } - - for (const action of this.actions) { - action.addJavaScriptLines(lines, indent, options); - - if (options.addTestIdlePause) { - AutoScriptGroup.addLine(lines, indent, "await test.idle(15);"); - } - } - } - - addCommandGroupLines(lines: string[], indent: number, options: ICommandOptions) { - const req: ICommandRequirements = {}; - - for (const action of this.actions) { - AutoScriptGroup.mergeCommandRequirements(req, action.getCommandRequirements(options)); - } - - for (const action of this.actions) { - action.addCommandLines(lines, indent, options); - } - } - - static mergeScriptOptions(source: IScriptOptions, add: IScriptOptions) { - source.isFunction = source.isFunction || add.isFunction; - } - - static mergeScriptRequirements(source: IScriptRequirements, add: IScriptRequirements) { - source.needsLocalOverworld = source.needsLocalOverworld || add.needsLocalOverworld; - } - static mergeCommandRequirements(source: ICommandRequirements, add: ICommandRequirements) {} - - static addLine(lines: string[], indent: number, line: string) { - lines.push(this.getIndentSpaces(indent) + line); - } - - static getIndentSpaces(indent: number) { - let result = ""; - - for (let i = 0; i < indent; i++) { - result += " "; - } - - return result; - } - - ensureLoaded() { - if (this.data.actions) { - for (const actionData of this.data.actions) { - const action = this.getActionFromData(actionData); - this.actions.push(action); - } - } - } - - removeAction(removeAction: AutoScriptAction) { - const newActionArr: AutoScriptAction[] = []; - - for (const action of this.actions) { - if (action !== removeAction) { - newActionArr.push(action); - } - } - - this.actions = newActionArr; - } - - createAction(type: string) { - let action = undefined; - - switch (type) { - case "entity.spawn": - action = new EntitySpawnAction(this, { type: type }); - break; - case "simulatedplayer.spawn": - action = new SimulatedPlayerSpawnAction(this, { type: type }); - break; - case "simulatedplayer.move": - action = new SimulatedPlayerMoveAction(this, { type: type }); - break; - case "idle": - action = new IdleAction(this, { type: type }); - break; - } - - if (action) { - this.actions.push(action); - - if (!this.data.actions) { - this.data.actions = []; - } - - this.data.actions.push(action.data); - } - } - - getActionFromData(data: IAutoScriptAction): AutoScriptAction { - switch (data.type) { - case "entity.spawn": - return new EntitySpawnAction(this, data); - - case "simulatedplayer.spawn": - return new SimulatedPlayerSpawnAction(this, data); - - case "simulatedplayer.move": - return new SimulatedPlayerMoveAction(this, data); - - case "idle": - return new IdleAction(this, data); - - default: - throw new Error("Unexpected action type: " + data.type); - } - } -} diff --git a/app/src/autoscript/AutoScriptScope.ts b/app/src/autoscript/AutoScriptScope.ts deleted file mode 100644 index f8aef05a..00000000 --- a/app/src/autoscript/AutoScriptScope.ts +++ /dev/null @@ -1,49 +0,0 @@ -import Test from "../gameTest/Test"; -import IWorld from "../minecraft/IWorld"; -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptError from "./AutoScriptError"; - -export default class AutoScriptScope { - parent: AutoScriptScope | undefined; - - test: Test | undefined; - world: IWorld | undefined; - errors: AutoScriptError[] = []; - - state: { [name: string]: object } = {}; - - getState(name: string): object | undefined { - const result = this.state[name]; - - if (!result && this.parent) { - return this.parent.getState(name); - } - - return result; - } - - setState(name: string, val: object) { - this.state[name] = val; - } - - addError(action: AutoScriptAction, message: string) { - const error = new AutoScriptError(action, message); - - this.addErrorDirect(error); - } - - addErrorDirect(error: AutoScriptError) { - this.errors.push(error); - - if (this.parent) { - this.parent.addErrorDirect(error); - } - } - - createBlockLocation(name: string) { - const val = this.getState(name); - - if (val instanceof Array) { - } - } -} diff --git a/app/src/autoscript/BlockBrokenAction.ts b/app/src/autoscript/BlockBrokenAction.ts deleted file mode 100644 index ce7ac376..00000000 --- a/app/src/autoscript/BlockBrokenAction.ts +++ /dev/null @@ -1,96 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptOptions from "./IScriptOptions.js"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import BlockLocation from "./../minecraft/BlockLocation"; -import ICommandRequirements from "./ICommandRequirements.js"; -import SimulatedPlayer from "../gameTest/SimulatedPlayer.js"; -import AutoScriptScope from "./AutoScriptScope.js"; - -export default class BlockBrokenAction extends AutoScriptAction { - get shortSubjectId() { - return "blockBroken"; - } - - get typeTitle() { - return "Block Broken Action"; - } - - get title() { - let title = this.typeTitle; - - if (this.location) { - title += " " + this.location.toSummary(); - } - - return title; - } - - get location() { - return this.getArgumentAsBlockLocation("location"); - } - - set location(location: BlockLocation | undefined) { - if (!location) { - (this.data as any)["location"] = undefined; - } else { - (this.data as any)["location"] = [location.x, location.y, location.z]; - } - } - - validate() { - this.validateArgumentIsType("location", "BlockLocation"); - - return true; - } - - getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements { - return { - needsTest: true, - }; - } - - getCommandRequirements(options: ICommandOptions): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number, options: ICommandOptions) { - let location = this.location; - - if (!location) { - location = new BlockLocation(0, 0, 0); - } - - AutoScriptGroup.addLine(lines, indent, "tag @p[l=1] add " + this.getCommandSet()); - } - - run(scope: AutoScriptScope) { - if (!scope.test) { - scope.addError(this, "Test is not specified"); - return; - } - - if (!this.location) { - scope.addError(this, "Location is not specified"); - return; - } - - //const simPlayer = scope.test.spawnSimulatedPlayer(this.location); - - const simPlayer = scope.getState(this.setId) as SimulatedPlayer; - - if (simPlayer) { - simPlayer.interact(); - } - //scope.setState(this.setId, simPlayer); - } - - addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions) { - if (!this.location) { - throw new Error(); - } - - AutoScriptGroup.addLine(lines, indent, this.getScriptSet() + ".interact();"); - } -} diff --git a/app/src/autoscript/EntitySpawnAction.ts b/app/src/autoscript/EntitySpawnAction.ts deleted file mode 100644 index 420c96ad..00000000 --- a/app/src/autoscript/EntitySpawnAction.ts +++ /dev/null @@ -1,94 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandRequirements from "./ICommandRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import IScriptOptions from "./IScriptOptions.js"; -import Location from "../minecraft/Location"; - -export default class EntitySpawnAction extends AutoScriptAction { - get typeTitle() { - return "Spawn Entity"; - } - - get title() { - if (!this.entityType) { - return this.typeTitle; - } - - return this.typeTitle + " " + this.entityType; - } - - get entityType() { - return this.getArgumentAsString("entityType"); - } - - get location() { - return this.getArgumentAsLocation("location"); - } - - getJavaScriptRequirements(): IScriptRequirements { - return { - needsLocalOverworld: true, - }; - } - - getCommandRequirements(): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number, options: ICommandOptions) { - if (!this.entityType) { - return; - } - - let loc = this.location; - - if (!loc) { - loc = new Location(0, 0, 0); - } - - AutoScriptGroup.addLine(lines, indent, "summon " + this.entityType + " " + loc.x + " " + loc.y + " " + loc.z); - } - - addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions) { - if (!this.entityType) { - return; - } - - let loc = this.location; - - if (!loc) { - loc = new Location(0, 0, 0); - } - - if (options.useGameTestApis) { - AutoScriptGroup.addLine( - lines, - indent, - 'test.spawnEntity("' + this.entityType + '", new Location(' + loc.x + ", " + loc.y + ", " + loc.z + "));" - ); - } else { - AutoScriptGroup.addLine( - lines, - indent, - 'overworld.spawnEntity("' + this.entityType + '", new Location(' + loc.x + ", " + loc.y + ", " + loc.z + "));" - ); - } - } - - validate() { - this.validateArgumentIsType("location", "Location"); - this.validateArgumentIsEntityType("entityType"); - - return true; - } - - getCommand() { - return ""; - } - - getJavaScript() { - return ""; - } -} diff --git a/app/src/autoscript/IAutoScriptAction.ts b/app/src/autoscript/IAutoScriptAction.ts deleted file mode 100644 index 1e01be00..00000000 --- a/app/src/autoscript/IAutoScriptAction.ts +++ /dev/null @@ -1,11 +0,0 @@ -import IAutoScriptClause from "./IAutoScriptClause.js"; - -export default interface IAutoScriptAction { - type: string; - args?: object; - condition?: IAutoScriptClause[]; - actions?: IAutoScriptAction[]; - value?: string; - withId?: string; - setId?: string; -} diff --git a/app/src/autoscript/IAutoScriptClause.ts b/app/src/autoscript/IAutoScriptClause.ts deleted file mode 100644 index c3bb001a..00000000 --- a/app/src/autoscript/IAutoScriptClause.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default interface IAutoScriptClause { - op: "<" | ">" | "=" | "!="; -} diff --git a/app/src/autoscript/IAutoScriptClauseGroup.ts b/app/src/autoscript/IAutoScriptClauseGroup.ts deleted file mode 100644 index bf6f6c63..00000000 --- a/app/src/autoscript/IAutoScriptClauseGroup.ts +++ /dev/null @@ -1,3 +0,0 @@ -import IAutoScriptClause from "./IAutoScriptClause.js"; - -export default interface IAutoScriptClauseGroup extends IAutoScriptClause {} diff --git a/app/src/autoscript/IAutoScriptData.ts b/app/src/autoscript/IAutoScriptData.ts deleted file mode 100644 index 8507699c..00000000 --- a/app/src/autoscript/IAutoScriptData.ts +++ /dev/null @@ -1,5 +0,0 @@ -import IAutoScriptGroup from "./IAutoScriptGroup.js"; - -export default interface IAutoScriptData extends IAutoScriptGroup { - name: string; -} diff --git a/app/src/autoscript/IAutoScriptGroup.ts b/app/src/autoscript/IAutoScriptGroup.ts deleted file mode 100644 index df7956e4..00000000 --- a/app/src/autoscript/IAutoScriptGroup.ts +++ /dev/null @@ -1,5 +0,0 @@ -import IAutoScriptAction from "./IAutoScriptAction.js"; - -export default interface IAutoScriptGroup { - actions: IAutoScriptAction[]; -} diff --git a/app/src/autoscript/ICommandOptions.ts b/app/src/autoscript/ICommandOptions.ts deleted file mode 100644 index 5b0ee9a3..00000000 --- a/app/src/autoscript/ICommandOptions.ts +++ /dev/null @@ -1,3 +0,0 @@ -export default interface ICommandOptions { - isFunction?: boolean; -} diff --git a/app/src/autoscript/ICommandRequirements.ts b/app/src/autoscript/ICommandRequirements.ts deleted file mode 100644 index 4fef44db..00000000 --- a/app/src/autoscript/ICommandRequirements.ts +++ /dev/null @@ -1 +0,0 @@ -export default interface ICommandRequirements {} diff --git a/app/src/autoscript/IScriptArea.ts b/app/src/autoscript/IScriptArea.ts deleted file mode 100644 index 976bf58b..00000000 --- a/app/src/autoscript/IScriptArea.ts +++ /dev/null @@ -1,7 +0,0 @@ -import IAutoScriptData from "./IAutoScriptData.js"; - -export default interface IAutoScriptArea { - name: string; - location: number[]; - script: IAutoScriptData; -} diff --git a/app/src/autoscript/IScriptOptions.ts b/app/src/autoscript/IScriptOptions.ts deleted file mode 100644 index 38da1b7f..00000000 --- a/app/src/autoscript/IScriptOptions.ts +++ /dev/null @@ -1,5 +0,0 @@ -export default interface IScriptOptions { - isFunction?: boolean; - addTestIdlePause?: boolean; - useGameTestApis?: boolean; -} diff --git a/app/src/autoscript/IScriptRequirements.ts b/app/src/autoscript/IScriptRequirements.ts deleted file mode 100644 index 559c07d6..00000000 --- a/app/src/autoscript/IScriptRequirements.ts +++ /dev/null @@ -1,4 +0,0 @@ -export default interface IScriptRequirements { - needsLocalOverworld?: boolean; - needsTest?: boolean; -} diff --git a/app/src/autoscript/ITestData.ts b/app/src/autoscript/ITestData.ts deleted file mode 100644 index c2f5bbbf..00000000 --- a/app/src/autoscript/ITestData.ts +++ /dev/null @@ -1,5 +0,0 @@ -import IScriptArea from "./IScriptArea.js"; - -export default interface ITestData { - areas: IScriptArea[]; -} diff --git a/app/src/autoscript/IdleAction.ts b/app/src/autoscript/IdleAction.ts deleted file mode 100644 index 3b2ae80e..00000000 --- a/app/src/autoscript/IdleAction.ts +++ /dev/null @@ -1,42 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptOptions from "./IScriptOptions.js"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import ICommandRequirements from "./ICommandRequirements.js"; - -export default class IdleAction extends AutoScriptAction { - get typeTitle() { - return "Idle"; - } - - get title() { - return this.typeTitle; - } - - get ticks() { - return this.getArgumentAsNumber("ticks"); - } - - validate() { - this.validateArgumentIsType("ticks", "number"); - - return true; - } - - getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements { - return { - needsTest: true, - }; - } - - getCommandRequirements(options: ICommandOptions): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number, optons: ICommandOptions) {} - - addJavaScriptLines(lines: string[], indent: number, optons: IScriptOptions) { - AutoScriptGroup.addLine(lines, indent, "await " + this.getScriptTest() + ".idle(" + this.ticks + ");"); - } -} diff --git a/app/src/autoscript/SimulatedPlayerInteractionAction.ts b/app/src/autoscript/SimulatedPlayerInteractionAction.ts deleted file mode 100644 index ca931e9d..00000000 --- a/app/src/autoscript/SimulatedPlayerInteractionAction.ts +++ /dev/null @@ -1,92 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptOptions from "./IScriptOptions.js"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import Location from "./../minecraft/Location"; -import ICommandRequirements from "./ICommandRequirements.js"; -import SimulatedPlayer from "../gameTest/SimulatedPlayer.js"; -import AutoScriptScope from "./AutoScriptScope.js"; - -export default class SimulatedPlayerInteractionAction extends AutoScriptAction { - get shortSubjectId() { - return "simplayer"; - } - - get typeTitle() { - return "Simulated Player Interaction"; - } - - get title() { - let title = this.typeTitle; - - if (this.location) { - title += " " + this.location.toSummary(); - } - - return title; - } - - get location() { - return this.getArgumentAsLocation("location"); - } - - set location(location: Location | undefined) { - if (!location) { - (this.data as any)["location"] = undefined; - } else { - (this.data as any)["location"] = [location.x, location.y, location.z]; - } - } - - validate() { - this.validateArgumentIsType("location", "Location"); - - return true; - } - - getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements { - return { - needsTest: true, - }; - } - - getCommandRequirements(options: ICommandOptions): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number, options: ICommandOptions) { - let location = this.location; - - if (!location) { - location = new Location(0, 0, 0); - } - - AutoScriptGroup.addLine(lines, indent, "tag @p[limit=1] add " + this.getCommandSet()); - } - - run(scope: AutoScriptScope) { - if (!scope.test) { - scope.addError(this, "Test is not specified"); - return; - } - - if (!this.location) { - scope.addError(this, "Location is not specified"); - return; - } - - //const simPlayer = scope.test.spawnSimulatedPlayer(this.location); - - const simPlayer = scope.getState(this.setId) as SimulatedPlayer; - - if (simPlayer) { - simPlayer.interact(); - } - //scope.setState(this.setId, simPlayer); - } - - addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions) { - AutoScriptGroup.addLine(lines, indent, this.getScriptSet() + ".interact();"); - } -} diff --git a/app/src/autoscript/SimulatedPlayerMoveAction.ts b/app/src/autoscript/SimulatedPlayerMoveAction.ts deleted file mode 100644 index 2af1226b..00000000 --- a/app/src/autoscript/SimulatedPlayerMoveAction.ts +++ /dev/null @@ -1,90 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptOptions from "./IScriptOptions"; -import IScriptRequirements from "./IScriptRequirements"; -import ICommandOptions from "./ICommandOptions"; -import ICommandRequirements from "./ICommandRequirements"; -import Location from "./../minecraft/Location"; - -export default class SimulatedPlayerMoveAction extends AutoScriptAction { - get typeTitle() { - return "Move Simulated Player"; - } - - get shortSubjectId() { - return "simplayer"; - } - - get title() { - if (!this.location) { - return this.typeTitle; - } - - return this.typeTitle + " " + this.location.toSummary(); - } - - get location() { - return this.getArgumentAsLocation("location"); - } - - set location(location: Location | undefined) { - if (!location) { - (this.data as any)["location"] = undefined; - } else { - (this.data as any)["location"] = [location.x, location.y, location.z]; - } - } - - validate() { - this.validateArgumentIsType("location", "Location"); - - return true; - } - - getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements { - return { - needsTest: true, - }; - } - - getCommandRequirements(options: ICommandOptions): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number) { - let location = this.location; - - if (!location) { - location = new Location(0, 0, 0); - } - - location = this.absolutizeLocation(location); - - AutoScriptGroup.addLine( - lines, - indent, - "tp @p[tag=" + this.getCommandWith() + "]" + location.x + " " + location.y + " " + location.z - ); - } - - addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions) { - let location = this.location; - - if (!location) { - location = new Location(0, 0, 0); - } - - AutoScriptGroup.addLine( - lines, - indent, - this.getScriptWith() + - ".moveToLocation(new Location(" + - location.x + - ", " + - location.y + - ", " + - location.z + - "));" - ); - } -} diff --git a/app/src/autoscript/SimulatedPlayerSpawnAction.ts b/app/src/autoscript/SimulatedPlayerSpawnAction.ts deleted file mode 100644 index a5235f94..00000000 --- a/app/src/autoscript/SimulatedPlayerSpawnAction.ts +++ /dev/null @@ -1,110 +0,0 @@ -import AutoScriptAction from "./AutoScriptAction"; -import AutoScriptGroup from "./AutoScriptGroup"; -import IScriptOptions from "./IScriptOptions.js"; -import IScriptRequirements from "./IScriptRequirements.js"; -import ICommandOptions from "./ICommandOptions.js"; -import BlockLocation from "./../minecraft/BlockLocation"; -import ICommandRequirements from "./ICommandRequirements.js"; -import AutoScriptScope from "./AutoScriptScope.js"; - -export default class SimulatedPlayerSpawnAction extends AutoScriptAction { - get shortSubjectId() { - return "simplayer"; - } - - get typeTitle() { - return "Spawn Simulated Player"; - } - - get title() { - let title = this.typeTitle; - - if (this.location) { - title += " " + this.location.toSummary(); - } - - return title; - } - - get location() { - return this.getArgumentAsBlockLocation("location"); - } - - set location(location: BlockLocation | undefined) { - if (!location) { - (this.data as any)["location"] = undefined; - } else { - (this.data as any)["location"] = [location.x, location.y, location.z]; - } - } - - validate() { - this.validateArgumentIsType("location", "Location"); - - return true; - } - - getJavaScriptRequirements(options: IScriptOptions): IScriptRequirements { - return { - needsTest: true, - }; - } - - getCommandRequirements(options: ICommandOptions): ICommandRequirements { - return {}; - } - - addCommandLines(lines: string[], indent: number, options: ICommandOptions) { - let location = this.location; - - if (!location) { - location = new BlockLocation(0, 0, 0); - } - - location = this.absolutizeBlockLocation(location); - - AutoScriptGroup.addLine(lines, indent, "tag @p[l=1] add " + this.getCommandSet()); - } - - run(scope: AutoScriptScope) { - if (!scope.test) { - scope.addError(this, "Test is not specified"); - return; - } - - if (!this.location) { - scope.addError(this, "Location is not specified"); - return; - } - - const simPlayer = scope.test.spawnSimulatedPlayer(this.location); - - scope.setState(this.setId, simPlayer); - } - - addJavaScriptLines(lines: string[], indent: number, options: IScriptOptions) { - let location = this.location; - - if (!location) { - location = new BlockLocation(0, 0, 0); - } - - AutoScriptGroup.addLine( - lines, - indent, - "const " + - this.getScriptSet() + - " = " + - this.getScriptTest() + - ".spawnSimulatedPlayer(new BlockLocation(" + - location.x + - ", " + - location.y + - ", " + - location.z + - '), "' + - this.getScriptSet() + - '");' - ); - } -} diff --git a/app/src/clientapp/MinecraftGameProxyMinecraft.ts b/app/src/clientapp/MinecraftGameProxyMinecraft.ts deleted file mode 100644 index 94f61fc9..00000000 --- a/app/src/clientapp/MinecraftGameProxyMinecraft.ts +++ /dev/null @@ -1,300 +0,0 @@ -import Carto, { CartoMinecraftErrorStatus, CartoMinecraftState } from "../app/Carto"; -import IMinecraft, { IMinecraftMessage, PrepareAndStartResultType } from "../app/IMinecraft"; -import AppServiceProxy, { AppServiceProxyCommands } from "../core/AppServiceProxy"; -import { EventDispatcher } from "ste-events"; -import Utilities from "../core/Utilities"; -import Project from "../app/Project"; -import MinecraftPush from "../app/MinecraftPush"; -import GameStateManager from "../minecraft/GameStateManager"; -import Log from "../core/Log"; -import ProjectTools from "../app/ProjectTools"; -import IFolder from "../storage/IFolder"; -import { MinecraftGameConnectionMode } from "../app/ICartoData"; -import ProjectExporter from "../app/ProjectExporter"; -import { ICommandResponseBody } from "../minecraft/ICommandResponse"; - -export default class MinecraftGameProxyMinecraft implements IMinecraft { - private _carto: Carto; - state: CartoMinecraftState; - private _onStateChanged = new EventDispatcher(); - private _onRefreshed = new EventDispatcher(); - private _project: Project | undefined; - private _gameStateManager: GameStateManager; - - errorStatus?: CartoMinecraftErrorStatus; - errorMessage?: string; - - worldFolder: IFolder | undefined; - projectFolder: IFolder | undefined; - - private _onWorldFolderReady = new EventDispatcher(); - private _onProjectFolderReady = new EventDispatcher(); - private _onMessage = new EventDispatcher(); - - public get onWorldFolderReady() { - return this._onWorldFolderReady.asEvent(); - } - - public get onProjectFolderReady() { - return this._onProjectFolderReady.asEvent(); - } - - public get onMessage() { - return this._onMessage.asEvent(); - } - - get canDeployFiles() { - return this._carto.minecraftGameMode !== MinecraftGameConnectionMode.remoteMinecraft; - } - - public get onRefreshed() { - return this._onRefreshed.asEvent(); - } - - public get onStateChanged() { - return this._onStateChanged.asEvent(); - } - - constructor(carto: Carto) { - this._carto = carto; - this._gameStateManager = new GameStateManager(this._carto); - - this.state = CartoMinecraftState.none; - } - - async updateStatus() { - return this.state; - } - - get activeProject() { - return this._project; - } - - set activeProject(newProject: Project | undefined) { - this._project = newProject; - } - - public get gameStateManager() { - return this._gameStateManager; - } - - public notifyStateChanged(newVal: CartoMinecraftState) { - this.state = newVal; - - this._onStateChanged.dispatch(this, newVal); - } - - async initialize() { - await this.start(); - } - - async prepare(force?: boolean) {} - - async pushWorld() { - if (!this._carto || this._carto.deploymentStorage === null || !this._project) { - return; - } - - let name = this._project.name + "_mct"; - - const worldsFolder = await ProjectExporter.ensureMinecraftWorldsFolder(this._carto); - - if (!worldsFolder) { - Log.debug("Could not find a Minecraft world."); - return; - } - - const worldFolder = worldsFolder.ensureFolder(name); - - await worldFolder.ensureExists(); - - // Log.debugAlert("Exporting folder to '" + worldFolder.storageRelativePath + "'"); - await ProjectExporter.syncFlatPackRefWorldTo(this._carto, this._project, worldFolder, name); - - name = Utilities.getSimpleString(this._project.name) + "_mct"; - - await worldFolder.saveAll(); - - return name; - } - - async deploy() { - if ( - this._carto.deploymentStorage == null || - this._carto.deployBehaviorPacksFolder == null || - this._carto.minecraftGameMode === MinecraftGameConnectionMode.remoteMinecraft - ) { - throw new Error("This instance doesn't support deployment"); - } - - if (!this._project) { - return; - } - - const deployFolderExists = await this._carto.deployBehaviorPacksFolder.exists(); - - if (deployFolderExists) { - await ProjectTools.deployProject( - this._carto, - this._project, - this._carto.deploymentStorage, - this._carto.deployBehaviorPacksFolder - ); - } - } - - processExternalMessage(command: string, data: string) { - switch (command) { - case "wsevent": - let obj = undefined; - - try { - obj = JSON.parse(data); - } catch (e) {} - - if (obj) { - this._gameStateManager.handleEvent(obj); - } - - break; - - case "webSocketCommandComplete": - Log.message(data); - break; - - case "webSocketConnected": - this.notifyStateChanged(CartoMinecraftState.started); - - if (!this._carto.successfullyConnectedWebSocketToMinecraft) { - this._carto.successfullyConnectedWebSocketToMinecraft = true; - this._carto.save(); - } - break; - - case "webSocketDisconnected": - this.notifyStateChanged(CartoMinecraftState.disconnected); - break; - } - } - - async runCommand(command: string) { - if (!AppServiceProxy.hasAppService && Utilities.isDebug) { - // simulate a command in debug - Log.debugAlert("Simulating command to Minecraft:\r\n\r\n" + command + "\r\n\r\n"); - - if (command.indexOf("fail") >= 0) { - return JSON.stringify({ - statusCode: -2147483648, - statusMessage: "Failed command " + command, - }); - } else { - return JSON.stringify({ - statusCode: 0, - statusMessage: "Success command " + command, - position: { - x: -100, - y: 100, - z: -100, - }, - }); - } - } else { - const result = await AppServiceProxy.sendAsync(AppServiceProxyCommands.webSocketCommand, command); - - this.logCommandResult(result); - - return result; - } - } - - logCommandResult(result: string) { - if (result) { - if (result.indexOf("{") >= 0) { - try { - const commandResponse: ICommandResponseBody = JSON.parse(result); - - if (commandResponse.statusMessage) { - this._carto.notifyStatusUpdate("Minecraft Game: " + commandResponse.statusMessage); - return; - } - } catch (e: any) { - Log.fail(e); - } - } - } - this._carto.notifyStatusUpdate("Minecraft Game: " + result); - } - - canPrepare() { - return true; - } - - async prepareAndStart(push: MinecraftPush) { - let worldName = undefined; - - if (push.project) { - this._project = push.project; - - await this.deploy(); - } - - if (push.worldType) { - worldName = await this.pushWorld(); - } - - await this.start(); - - return { - type: PrepareAndStartResultType.started, - worldName: worldName, - }; - } - - async stop() {} - - async start() { - if (!AppServiceProxy.hasAppService && Utilities.isDebug) { - this.notifyStateChanged(CartoMinecraftState.stopped); - } else if ( - this.state === CartoMinecraftState.none || - this.state === CartoMinecraftState.error || - this.state === CartoMinecraftState.disconnected - ) { - this.notifyStateChanged(CartoMinecraftState.initializing); - - AppServiceProxy.sendAsync(AppServiceProxyCommands.startWebSocketServer, "").then(async (result: string) => { - const getMinecraftGameProjectDeployDir = await AppServiceProxy.sendAsync( - AppServiceProxyCommands.getMinecraftGameProjectDeployDir, - this._carto.minecraftGameMode - ); - - const getMinecraftGameWorldDeployDir = await AppServiceProxy.sendAsync( - AppServiceProxyCommands.getMinecraftGameWorldDeployDir, - this._carto.minecraftGameMode - ); - - if ( - getMinecraftGameWorldDeployDir && - getMinecraftGameWorldDeployDir.length > 0 && - this._carto.ensureLocalFolder - ) { - this.worldFolder = this._carto.ensureLocalFolder(getMinecraftGameWorldDeployDir); - - this._onWorldFolderReady.dispatch(this, this.worldFolder); - } - - if ( - getMinecraftGameProjectDeployDir && - getMinecraftGameProjectDeployDir.length > 0 && - this._carto.ensureLocalFolder - ) { - this.projectFolder = this._carto.ensureLocalFolder(getMinecraftGameProjectDeployDir); - - this._onProjectFolderReady.dispatch(this, this.projectFolder); - } - - this.notifyStateChanged(CartoMinecraftState.initialized); - }); - } - } -} diff --git a/app/src/clientapp/ProcessHostedProxyMinecraft.ts b/app/src/clientapp/ProcessHostedProxyMinecraft.ts deleted file mode 100644 index 356c9615..00000000 --- a/app/src/clientapp/ProcessHostedProxyMinecraft.ts +++ /dev/null @@ -1,361 +0,0 @@ -import Carto, { CartoMinecraftErrorStatus, CartoMinecraftState } from "../app/Carto"; -import IMinecraft, { IMinecraftMessage, PrepareAndStartResultType } from "../app/IMinecraft"; -import AppServiceProxy, { AppServiceProxyCommands } from "../core/AppServiceProxy"; -import { EventDispatcher } from "ste-events"; -import IStorage from "../storage/IStorage"; -import IFolder from "../storage/IFolder"; -import Log from "../core/Log"; -import Utilities from "../core/Utilities"; -import Project from "../app/Project"; -import ProjectExporter from "../app/ProjectExporter"; -import MinecraftPush from "../app/MinecraftPush"; -import GameStateManager from "../minecraft/GameStateManager"; -import { DedicatedServerMode } from "../app/ICartoData"; -import ProjectTools from "../app/ProjectTools"; -import { IMinecraftStartMessage } from "../app/IMinecraftStartMessage"; -import { IWorldSettings } from "../minecraft/IWorldSettings"; - -export default class ProcessHostedMinecraft implements IMinecraft { - private _carto: Carto; - - private _project: Project | undefined; - private _gameStateManager: GameStateManager; - errorStatus?: CartoMinecraftErrorStatus; - errorMessage?: string; - - state: CartoMinecraftState; - dedicatedServerStorage: IStorage | null; - private _dsDeployBehaviorPacksFolder: IFolder | null; - - worldFolder: IFolder | undefined; - projectFolder: IFolder | undefined; - - private _onWorldStorageReady = new EventDispatcher(); - private _onProjectStorageReady = new EventDispatcher(); - private _onMessage = new EventDispatcher(); - private _onStateChanged = new EventDispatcher(); - private _onRefreshed = new EventDispatcher(); - - public get onWorldFolderReady() { - return this._onWorldStorageReady.asEvent(); - } - - public get onProjectFolderReady() { - return this._onProjectStorageReady.asEvent(); - } - - public get onMessage() { - return this._onMessage.asEvent(); - } - - public get gameStateManager() { - return this._gameStateManager; - } - - public get onRefreshed() { - return this._onRefreshed.asEvent(); - } - - public get onStateChanged() { - return this._onStateChanged.asEvent(); - } - - get activeProject() { - return this._project; - } - - set activeProject(newProject: Project | undefined) { - this._project = newProject; - } - - get canDeployFiles() { - return true; - } - - constructor(carto: Carto) { - this._carto = carto; - this._gameStateManager = new GameStateManager(this._carto); - - this.dedicatedServerStorage = null; - this.state = CartoMinecraftState.none; - - this._dsDeployBehaviorPacksFolder = null; - - this.updateStatus(); - } - - async updateStatus() { - const result = await AppServiceProxy.sendAsync(AppServiceProxyCommands.getDedicatedServerStatus, ""); - - if (result) { - let resultNum = -1; - try { - resultNum = parseInt(result); - } catch (e) {} - - if (resultNum >= 0) { - if (resultNum === 1) { - this.notifyStateChanged(CartoMinecraftState.stopped); - } else if (resultNum === 2) { - this.notifyStateChanged(CartoMinecraftState.initializing); - } else if (resultNum === 3) { - this.notifyStateChanged(CartoMinecraftState.preparing); - } else if (resultNum === 4) { - this.notifyStateChanged(CartoMinecraftState.starting); - } else if (resultNum === 5) { - this.notifyStateChanged(CartoMinecraftState.started); - } - } - } - - return this.state; - } - - async prepare(force?: boolean) {} - - processExternalMessage(command: string, data: string) { - switch (command) { - case "dedicatedServerStarted": - this.notifyStateChanged(CartoMinecraftState.started); - - if (!this._carto.successfullyStartedMinecraftServer) { - this._carto.successfullyStartedMinecraftServer = true; - this._carto.save(); - } - - break; - - case "dedicatedServerRefreshed": - this.notifyRefreshed(); - break; - - case "dedicatedServerStopped": - this.notifyStateChanged(CartoMinecraftState.stopped); - break; - - case "dedicatedServerGameEvents": - this.notifyGameEvents(data); - break; - - case "dedicatedServerMessage": - this._carto.notifyStatusUpdate("Server: " + data); - break; - - case "dedicatedServerError": - this._carto.notifyStatusUpdate("Server Error: " + data); - break; - } - } - - async initialize() { - await this.start(); - } - - get dedicatedServerBehaviorPacksFolder(): IFolder | null { - return this._dsDeployBehaviorPacksFolder; - } - - private notifyGameEvents(data: string) { - let obj = undefined; - - try { - obj = JSON.parse(data); - } catch (e) {} - - if (!obj || !obj.length) { - return; - } - - for (let i = 0; i < obj.length; i++) { - const event = obj[i]; - - this._gameStateManager?.handleEvent(event); - } - } - - private _updateDedicatedServerStorage() { - if ( - this._carto.ensureLocalFolder === undefined || - !AppServiceProxy.hasAppService || - this._carto.dedicatedServerPath === undefined - ) { - return; - } - - const folder = this._carto.ensureLocalFolder(this._carto.dedicatedServerPath); - - this.dedicatedServerStorage = folder.storage; - - if (this.dedicatedServerStorage != null) { - this._dsDeployBehaviorPacksFolder = - this.dedicatedServerStorage.rootFolder.ensureFolder("development_behavior_packs"); - } else { - this._dsDeployBehaviorPacksFolder = null; - } - } - - public notifyStateChanged(newVal: CartoMinecraftState) { - this.state = newVal; - - this._onStateChanged.dispatch(this, newVal); - } - - public notifyRefreshed(newVal?: CartoMinecraftState) { - if (newVal) { - this.state = newVal; - } - - this._onRefreshed.dispatch(this, this.state); - } - - async start() { - const path = this.getDedicatedServerSyntax(); - - this.notifyStateChanged(CartoMinecraftState.starting); - - await AppServiceProxy.sendAsync(AppServiceProxyCommands.startDedicatedServer, path); - } - - async prepareDedicatedServer(project: Project) { - await this.deploy(); - return await this.deployDedicatedServerWorld(project); - } - - async restartDedicatedServer(project: Project) { - await this.stop(); - - await this.prepareDedicatedServer(project); - - await this.start(); - } - - canPrepare() { - return true; - } - - async prepareAndStart(push: MinecraftPush) { - let worldName = undefined; - - if (this._project) { - worldName = await this.prepareDedicatedServer(this._project); - } - - await this.start(); - - return { - type: PrepareAndStartResultType.started, - worldName: worldName, - }; - } - - async deploy() { - if (this._carto.ensureLocalFolder == null) { - throw new Error("This instance doesn't support deployment"); - } - - if (!this._project) { - return; - } - - const folderPath = await AppServiceProxy.sendAsync(AppServiceProxyCommands.getDedicatedServerProjectDeployDir, ""); - - const deployFolder = await this._carto.ensureLocalFolder(folderPath); - - const deployFolderExists = deployFolder; - - if (deployFolderExists) { - await ProjectTools.deployProject(this._carto, this._project, deployFolder.storage, deployFolder); - } - } - - async runCommand(command: string) { - const result = await AppServiceProxy.sendAsync(AppServiceProxyCommands.dedicatedServerCommand, command); - - return result; - } - - async deployDedicatedServerWorld(project: Project) { - if (this.dedicatedServerStorage === null) { - return; - } - - const name = project.name + "_mct"; - const worldFolder = this.dedicatedServerStorage.rootFolder.ensureFolder("worlds").ensureFolder(name); - - await worldFolder.ensureExists(); - - // Log.debugAlert("Exporting folder to '" + worldFolder.storageRelativePath + "'"); - await ProjectExporter.syncFlatPackRefWorldTo(this._carto, project, worldFolder, name); - - /* - name = project.name + "FPAA"; - worldFolder = this.dedicatedServerStorage.rootFolder.ensureFolder("worlds").ensureFolder(name); - - await worldFolder.ensureExists(); - - await ProjectExporter.syncFlatPackRefWorldTo(this._carto, project, worldFolder, name); - const spm = new ServerPropertiesManager(); - - spm.serverFolder = this.dedicatedServerStorage.rootFolder; - spm.levelName = name; - await spm.writeFile();*/ - - await worldFolder.saveAll(); - - return name; - } - - getDedicatedServerSyntax() { - if (!this._carto.worldSettings) { - Log.debugAlert("World settings are not defined."); - throw new Error(); - } - - if ( - this._carto.dedicatedServerMode !== DedicatedServerMode.auto && - (this._carto.dedicatedServerPath === null || this._carto.dedicatedServerPath === undefined) - ) { - Log.debugAlert("Server folder path is not defined, and the path cannot be set."); - throw new Error(); - } - - let path = this._carto.dedicatedServerPath; - - if (!path) { - path = ""; - } - - let worldSettings: IWorldSettings = this._carto.worldSettings; - - if (this._project && this._project.worldSettings) { - if (this._project.worldSettings.useCustomSettings) { - worldSettings = this._project.worldSettings; - } - } - - if (!worldSettings.name) { - worldSettings.name = "world"; - } - - const mess: IMinecraftStartMessage = { - path: Utilities.ensureEndsWithBackSlash(path), - iagree: this._carto.iAgreeToTheMinecraftEndUserLicenseAgreementAndPrivacyPolicyAtMinecraftDotNetSlashTerms - ? true - : false, - mode: this._carto.dedicatedServerMode, - track: this._carto.processHostedMinecraftTrack, - backupContainerPath: "", - worldSettings: worldSettings, - }; - - return JSON.stringify(mess); - } - - async stop() { - const path = this.getDedicatedServerSyntax(); - - this.notifyStateChanged(CartoMinecraftState.stopping); - - await AppServiceProxy.sendAsync(AppServiceProxyCommands.stopDedicatedServer, path); - } -} diff --git a/app/src/dataform/MinecraftFilter.tsx b/app/src/dataform/MinecraftFilter.tsx index 761ddc5c..3fe99cdf 100644 --- a/app/src/dataform/MinecraftFilter.tsx +++ b/app/src/dataform/MinecraftFilter.tsx @@ -46,7 +46,7 @@ export default class MinecraftFilter extends Component, key: "add", onClick: this._addItem, - title: "Toggle whether recording actions", + title: "Add item", }); return ( diff --git a/app/src/gameTest/FenceConnectivity.ts b/app/src/gameTest/FenceConnectivity.ts deleted file mode 100644 index caeae2f4..00000000 --- a/app/src/gameTest/FenceConnectivity.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Returns information about whether this fence is connected to - * other fences in several directions. - */ -export class FenceConnectivity { - /** - * Represents whether this fence block is connected to another - * fence to the east (x + 1). - */ - readonly "east": boolean; - /** - * Represents whether this fence block is connected to another - * fence to the north (z - 1). - */ - readonly "north": boolean; - /** - * Represents whether this fence block is connected to another - * fence to the south (z + 1). - */ - readonly "south": boolean; - /** - * Represents whether this fence block is connected to another - * fence to the west (x - 1). - */ - readonly "west": boolean; -} diff --git a/app/src/gameTest/SimulatedPlayer.ts b/app/src/gameTest/SimulatedPlayer.ts deleted file mode 100644 index 4c31e68d..00000000 --- a/app/src/gameTest/SimulatedPlayer.ts +++ /dev/null @@ -1,609 +0,0 @@ -import Block from "../minecraft/Block"; -import BlockLocation from "../minecraft/BlockLocation"; -import BlockRaycastOptions from "../minecraft/BlockRaycastOptions"; -import Effect from "../minecraft/Effect"; -import EffectType from "../minecraft/EffectType"; -import Entity from "../minecraft/Entity"; -import EntityRaycastOptions from "../minecraft/EntityRaycastOptions"; -import { GameMode } from "../minecraft/GameMode"; -import IDimension from "../minecraft/IDimension"; -import IEntityComponent from "../minecraft/IEntityComponent"; -import ItemStack from "../minecraft/ItemStack"; -import { NavigationResult } from "../minecraft/NavigationResult"; -import PitchYawRotation from "../minecraft/PitchYawRotation"; -import Player from "../minecraft/Player"; -import Location from "../minecraft/Location"; - -/** - * A simulated player can be used within GameTests to represent - * how a player moves throughout the world and to support - * testing of how entities and the environment will react to a - * player. This type derives much of its structure and methods - * from the {@link mojang-minecraft.Player} type. - */ -export default class SimulatedPlayer extends Player { - /** - * Rotation of the body in degrees. Range is between -180 and - * 180 degrees. - * @throws This property can throw when used. - */ - readonly "bodyRotation": number; - /** - * Dimension that the simulated player is currently within. - * @throws This property can throw when used. - */ - readonly "dimension": IDimension; - /** - * Rotation of the head across pitch and yaw angles. - * @throws This property can throw when used. - */ - readonly "headRotation": PitchYawRotation; - /** - * True if the player is currently using a sneaking movement. - */ - "isSneaking": boolean; - /** - * Current location of the player. - * @throws This property can throw when used. - */ - readonly "location": Location; - /** - * Name of the player. - * @throws This property can throw when used. - */ - readonly "name": string; - /** - * Optional name tag of the player. - */ - "nameTag": string; - /** - * Manages the selected slot in the player's hotbar. - */ - "selectedSlot": number; - /** - * Retrieves or sets an entity that is used as the target of - * AI-related behaviors, like attacking. - */ - "target": Entity; - /** - * Current speed of the player across X, Y, and Z dimensions. - * @throws This property can throw when used. - */ - readonly "velocity": Location; - /** - * @remarks - * Adds an effect, like poison, to the entity. - * @param effectType - * Type of effect to add to the entity. - * @param duration - * Amount of time, in seconds, for the effect to apply. - * @param amplifier - * Optional amplification of the effect to apply. - * @throws This function can throw errors. - */ - addEffect(effectType: EffectType, duration: number, amplifier: number): void {} - /** - * @remarks - * Adds a specified tag to a simulated player. - * @param tag - * Content of the tag to add. - * @throws This function can throw errors. - */ - addTag(tag: string): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to make an attack 'swipe'. - * Returns true if the attack was performed - for example, the - * player was not on cooldown and had a valid target. Target - * selection is performed by raycasting from the player's head. - * @throws This function can throw errors. - */ - attack(): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to attack the provided target. - * Returns true if the attack was performed - for example, the - * player was not on cooldown and had a valid target. The - * attack can be performed at any distance and does not require - * line of sight to the target entity. - * @param entity - * @throws This function can throw errors. - */ - attackEntity(entity: Entity): boolean { - return false; - } - /** - * @remarks - * Destroys the block at blockLocation, respecting the rules of - * the server player's game mode. The block will be hit until - * broken, an item is used or stopBreakingBlock is called. - * Returns true if the block at blockLocation is solid. - * @param blockLocation - * Location of the block to interact with. - * @param direction - * Direction to place the specified item within. - * @throws This function can throw errors. - */ - breakBlock(blockLocation: BlockLocation, direction?: number): boolean { - return false; - } - /** - * @remarks - * Gets the first block that intersects with the vector of the - * view of this entity. - * @param options - * Additional options for processing this raycast query. - * @throws This function can throw errors. - */ - getBlockFromViewVector(options?: BlockRaycastOptions): Block { - return new Block(); - } - /** - * @remarks - * Gets a component (that represents additional capabilities) - * for an entity. - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. If the component is not present on - * the entity, undefined is returned. - */ - getComponent(componentId: string): IEntityComponent | undefined { - return undefined; - } - /** - * @remarks - * Returns all components that are both present on this entity - * and supported by the API. - */ - getComponents(): IEntityComponent[] { - return []; - } - /** - * @remarks - * Returns the effect for the specified EffectType on the - * entity, or undefined if the effect is not present. - * @param effectType - * @returns - * Effect object for the specified effect, or undefined if the - * effect is not present. - * @throws This function can throw errors. - */ - getEffect(effectType: EffectType): Effect { - return new Effect(); - } - /** - * @remarks - * Gets the first entity that intersects with the vector of the - * view of this entity. - * @param options - * Additional options for processing this raycast query. - * @throws This function can throw errors. - */ - getEntitiesFromViewVector(options?: EntityRaycastOptions): Entity[] { - return []; - } - /** - * @remarks - * Gets the current item cooldown time for a particular - * cooldown category. - * @param itemCategory - * Specifies the cooldown category to retrieve the current - * cooldown for. - * @throws This function can throw errors. - */ - getItemCooldown(itemCategory: string): number { - return 0; - } - /** - * @remarks - * Returns all tags associated with this simulated player. - * @throws This function can throw errors. - */ - getTags(): string[] { - return []; - } - /** - * @remarks - * Gives the simulated player a particular item stack. - * @param itemStack - * Item to give. - * @param selectSlot - * Whether to set the selected slot once given. - * @throws This function can throw errors. - */ - giveItem(itemStack: ItemStack, selectSlot?: boolean): boolean { - return false; - } - /** - * @remarks - * Returns true if the specified component is present on this - * entity. - * @param componentId - * The identifier of the component (e.g., 'minecraft:rideable') - * to retrieve. If no namespace prefix is specified, - * 'minecraft:' is assumed. - */ - hasComponent(componentId: string): boolean { - return false; - } - /** - * @remarks - * Tests whether a simulated player has a particular tag. - * @param tag - * Identifier of the tag to test for. - * @throws This function can throw errors. - */ - hasTag(tag: string): boolean { - return false; - } - /** - * @remarks - * Performs a raycast from the player’s head and interacts with - * the first intersected block or entity. Returns true if the - * interaction was successful. Maximum range is 6 blocks. - * @throws This function can throw errors. - */ - interact(): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to interact with a block. The - * block at the specified block location must be solid. Returns - * true if the interaction was performed. - * @param blockLocation - * Location of the block to interact with. - * @param direction - * Direction to place the specified item within. - * @throws This function can throw errors. - */ - interactWithBlock(blockLocation: BlockLocation, direction?: number): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to interact with a mob. Returns - * true if the interaction was performed. - * @param entity - * Entity to interact with. - * @throws This function can throw errors. - */ - interactWithEntity(entity: Entity): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to jump. - * @returns - * True if a jump was performed. - * @throws This function can throw errors. - */ - jump(): boolean { - return false; - } - /** - * @remarks - * Kills this entity. The entity will drop loot as normal. - * @throws This function can throw errors. - */ - kill(): void {} - /** - * @remarks - * Rotates the simulated player's head/body to look at the - * given block location. - * @param blockLocation - * @throws This function can throw errors. - */ - lookAtBlock(blockLocation: BlockLocation): void {} - /** - * @remarks - * Rotates the simulated player's head/body to look at the - * given entity. - * @param entity - * @throws This function can throw errors. - */ - lookAtEntity(entity: Entity): void {} - /** - * @remarks - * Rotates the simulated player's head/body to look at the - * given location. - * @param location - * @throws This function can throw errors. - */ - lookAtLocation(location: Location): void {} - /** - * @remarks - * Orders the simulated player to walk in the given direction - * relative to the GameTest. - * @param westEast - * @param northSouth - * @param speed - * @throws This function can throw errors. - */ - move(westEast: number, northSouth: number, speed?: number): void {} - /** - * @remarks - * Orders the simulated player to walk in the given direction - * relative to the player's current rotation. - * @param leftRight - * @param backwardForward - * @param speed - * @throws This function can throw errors. - */ - moveRelative(leftRight: number, backwardForward: number, speed?: number): void {} - /** - * @remarks - * Orders the simulated player to move to the given block - * location in a straight line. If a move or navigation is - * already playing, this will override the last - * move/navigation. - * @param blockLocation - * @param speed - * @throws This function can throw errors. - */ - moveToBlock(blockLocation: BlockLocation, speed?: number): void {} - /** - * @remarks - * Orders the simulated player to move to the given location in - * a straight line. If a move or navigation is already playing, - * this will override the last move/navigation. - * @param location - * @param speed - * @throws This function can throw errors. - */ - moveToLocation(location: Location, speed?: number): void {} - /** - * @remarks - * Orders the simulated player to move to a specific block - * location using navigation. If a move or navigation is - * already playing, this will override the last move/walk. Note - * that if the simulated player gets stuck, that simulated - * player will stop. The player must be touching the ground in - * order to start navigation. - * @param blockLocation - * @param speed - * @throws This function can throw errors. - */ - navigateToBlock(blockLocation: BlockLocation, speed?: number): NavigationResult { - return new NavigationResult(); - } - /** - * @remarks - * Will use navigation to follow the selected entity to within - * a one block radius. If a move or navigation is already - * playing, this will override the last move/navigation. - * @param entity - * @param speed - * @throws This function can throw errors. - */ - navigateToEntity(entity: Entity, speed?: number): NavigationResult { - return new NavigationResult(); - } - /** - * @remarks - * Orders the simulated player to move to a specific location - * using navigation. If a move or navigation is already - * playing, this will override the last move/walk. Note that if - * the simulated player gets stuck, that simulated player will - * stop. The player must be touching the ground in order to - * start navigation. - * @param location - * @param speed - * @throws This function can throw errors. - */ - navigateToLocation(location: Location, speed?: number): NavigationResult { - return new NavigationResult(); - } - /** - * @remarks - * Use navigation to follow the route provided via the - * locations parameter. If a move or navigation is already - * playing, this will override the last move/navigation. - * @param locations - * A list of locations to use for routing. - * @param speed - * Net speed to use for doing the navigation. - * @throws This function can throw errors. - */ - navigateToLocations(locations: Location[], speed?: number): void { - return; - } - /** - * @remarks - * Removes a specified tag from a simulated player. - * @param tag - * Content of the tag to remove. - * @throws This function can throw errors. - */ - removeTag(tag: string): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to turn by the provided angle, - * relative to the player's current rotation. - * @param angleInDegrees - * @throws This function can throw errors. - */ - rotateBody(angleInDegrees: number): void {} - /** - * @remarks - * Runs a particular command from the context of this simulated - * player. - * @param commandString - * Command to run. Note that command strings should not start - * with slash. - * @returns - * For commands that return data, returns a JSON structure with - * command response values. - * @throws This function can throw errors. - * @example commands.js - * ```typescript - * player.runCommand("say You got a new high score!"); - * player.runCommand("scoreboard players set @s score 10"); - * - * ``` - */ - runCommand(commandString: string): any { - return undefined; - } - /** - * @remarks - * Causes the simulated player to turn to face the provided - * angle, relative to the GameTest. - * @param angleInDegrees - * @throws This function can throw errors. - */ - setBodyRotation(angleInDegrees: number): void {} - /** - * @remarks - * Sets the game mode that the simulated player is operating - * under. - * @param gameMode - * Game mode to set. - * @throws This function can throw errors. - */ - setGameMode(gameMode: GameMode): void {} - /** - * @remarks - * Sets a particular item for the simulated player. - * @param itemStack - * Item to set. - * @param slot - * Slot to place the given item in. - * @param selectSlot - * Whether to set the selected slot once set. - * @throws This function can throw errors. - */ - setItem(itemStack: ItemStack, slot: number, selectSlot?: boolean): boolean { - return false; - } - /** - * @remarks - * Sets the item cooldown time for a particular cooldown - * category. - * @param itemCategory - * Specifies the cooldown category to retrieve the current - * cooldown for. - * @param tickDuration - * Duration in ticks of the item cooldown. - * @throws This function can throw errors. - */ - startItemCooldown(itemCategory: string, tickDuration: number): void {} - /** - * @remarks - * Stops destroying the block that is currently being hit. - * @throws This function can throw errors. - */ - stopBreakingBlock(): void {} - /** - * @remarks - * Stops interacting with entities or blocks. - * @throws This function can throw errors. - */ - stopInteracting(): void {} - /** - * @remarks - * Stops moving/walking/following if the simulated player is - * moving. - * @throws This function can throw errors. - */ - stopMoving(): void {} - /** - * @remarks - * Stops using the currently active item. - * @throws This function can throw errors. - */ - stopUsingItem(): void {} - /** - * @remarks - * Triggers an entity type event. For every entity, a number of - * events are defined in an entities' definition for key entity - * behaviors; for example, creepers have a - * minecraft:start_exploding type event. - * @param eventName - * Name of the entity type event to trigger. If a namespace is - * not specified, minecraft: is assumed. - * @throws This function can throw errors. - */ - triggerEvent(eventName: string): void {} - /** - * @remarks - * Causes the simulated player to use an item. Does not consume - * the item. Returns false if the item is on cooldown. - * @param itemStack - * Item to use. - * @throws This function can throw errors. - */ - useItem(itemStack: ItemStack): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to hold and use an item in their - * inventory. - * @param slot - * Index of the inventory slot. - * @throws This function can throw errors. - */ - useItemInSlot(slot: number): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to use an item in their - * inventory on a block. The block at the specified block - * location must be solid. Returns true if the item was used. - * @param slot - * Index of the slot to use. - * @param blockLocation - * Location to use the item upon. - * @param direction - * Direction to place the specified item within. - * @param faceLocationX - * Block-face-relative X position where to place the item. - * @param faceLocationY - * Block-face-relative Y position where to place the item. - * @throws This function can throw errors. - */ - useItemInSlotOnBlock( - slot: number, - blockLocation: BlockLocation, - direction?: number, - faceLocationX?: number, - faceLocationY?: number - ): boolean { - return false; - } - /** - * @remarks - * Causes the simulated player to use an item on a block. The - * block at the specified block location must be solid. Returns - * true if the item was used. - * @param itemStack - * Item to use. - * @param blockLocation - * Location to use the item upon. - * @param direction - * Direction to place the specified item within. - * @param faceLocationX - * Block-face-relative X position where to place the item. - * @param faceLocationY - * Block-face-relative Y position where to place the item. - * @throws This function can throw errors. - */ - useItemOnBlock( - itemStack: ItemStack, - blockLocation: BlockLocation, - direction?: number, - faceLocationX?: number, - faceLocationY?: number - ): boolean { - return false; - } -} diff --git a/app/src/gameTest/Test.ts b/app/src/gameTest/Test.ts deleted file mode 100644 index 1115fee5..00000000 --- a/app/src/gameTest/Test.ts +++ /dev/null @@ -1,902 +0,0 @@ -import BlockType from "./../minecraft/BlockType"; -import BlockLocation from "./../minecraft/BlockLocation"; -import Block from "./../minecraft/Block"; -import Entity from "./../minecraft/Entity"; -import ItemStack from "./../minecraft/ItemStack"; -import ItemTypeDefinition from "../minecraft/ItemTypeDefinition"; -import IDimension from "./../minecraft/IDimension"; -import BlockCube from "../minecraft/BlockCube"; -import { FenceConnectivity } from "./FenceConnectivity"; -import { Direction } from "../minecraft/Direction"; -import Location from "../minecraft/Location"; -import BlockPermutation from "../minecraft/BlockPermutation"; -import SimulatedPlayer from "./SimulatedPlayer"; -import { GameMode } from "../minecraft/GameMode"; - -export default class Test { - /** - * @remarks - * Tests that the condition specified in _condition_ is true. - * If not, an error with the specified _message_ is thrown. - * @param condition - * Expression of the condition to evaluate. - * @param message - * Message that is passed if the _condition_ does not evaluate - * to true. - * @throws This function can throw errors. - */ - assert(condition: boolean, message: string): void {} - /** - * @remarks - * Tests that a block of the specified type is present at the - * specified location. If it is not, an exception is thrown. - * @param blockType - * Expected block type. - * @param blockLocation - * Location of the block to test at. - * @param isPresent - * If true, this function tests whether a block of the - * specified type is at the location. If false, tests that a - * block of the specified type is not present. - * @throws This function can throw errors. - */ - assertBlockPresent(blockType: BlockType, blockLocation: BlockLocation, isPresent?: boolean): void {} - /** - * @remarks - * Tests that a block has a particular state value at the - * specified location. If it does not have that state value, an - * exception is thrown. - * @param blockLocation - * Location of the block to test at. - * @param callback - * Callback function that contains additional tests based on - * the block at the specified location. - * @throws This function can throw errors. - * @example testIfButtonNotPressed.js - * ```typescript - * test.assertBlockState(buttonPos, (block) => { - * return block.getBlockData().getProperty("button_pressed_bit") == 0; - * }); - * ``` - */ - assertBlockState(blockLocation: BlockLocation, callback: (arg: Block) => boolean): void {} - /** - * @remarks - * Tests that an entity can reach a particular location. - * Depending on the value of canReach, throws an exception if - * the condition is not met. - * @param mob - * Entity that you wish to test the location against. - * @param blockLocation - * Structure-relative location to test whether the specified - * mob can reach. - * @param canReach - * If true, tests whether the mob can reach the location. If - * false, tests whether the mob is not able to reach the - * location. - * @throws This function can throw errors. - */ - assertCanReachLocation(mob: Entity, blockLocation: BlockLocation, canReach?: boolean): void {} - /** - * @remarks - * Tests that a container (e.g., a chest) at the specified - * location contains a specified of item stack. If not, an - * error is thrown. - * @param itemStack - * Represents the type of item to check for. The specified - * container must contain at least 1 item matching the item - * type defined in _itemStack_. - * @param blockLocation - * Location of the block with a container (for example, a - * chest) to test the contents of. - * @throws This function can throw errors. - */ - assertContainerContains(itemStack: ItemStack, blockLocation: BlockLocation): void {} - /** - * @remarks - * Tests that a container (e.g., a chest) at the specified - * location is empty. If not, an error is thrown. - * @param blockLocation - * Location of the block with a container (for example, a - * chest) to test is empty of contents. - * @throws This function can throw errors. - */ - assertContainerEmpty(blockLocation: BlockLocation): void {} - /** - * @remarks - * Tests that an entity has a specific piece of armor equipped. - * If not, an error is thrown. - * @param entityTypeIdentifier - * Identifier of the entity to match (e.g., - * 'minecraft:skeleton'). - * @param armorSlot - * Container slot index to test. - * @param armorName - * Name of the armor to look for. - * @param armorData - * Data value integer to look for. - * @param blockLocation - * Location of the entity with armor to test for. - * @param hasArmor - * Whether or not the entity is expected to have the specified - * armor equipped. - * @throws This function can throw errors. - * @example horseArmorTest.js - * ```typescript - * test.assertEntityHasArmor("minecraft:horse", armorSlotTorso, "diamond_horse_armor", 0, horseLocation, true); - * - * ``` - */ - assertEntityHasArmor( - entityTypeIdentifier: string, - armorSlot: number, - armorName: string, - armorData: number, - blockLocation: BlockLocation, - hasArmor?: boolean - ): void {} - /** - * @remarks - * Tests that an entity has a particular component. If not, an - * exception is thrown. - * @param entityTypeIdentifier - * Identifier of the specified entity (e.g., - * 'minecraft:skeleton'). If the namespace is not specified, - * 'minecraft:' is assumed. - * @param componentIdentifier - * Identifier of the component to check for. If the namespace - * is not specified, 'minecraft:' is assumed. - * @param blockLocation - * Location of the block with a container (for example, a - * chest.) - * @param hasComponent - * Determines whether to test that the component exists, or - * does not. - * @throws This function can throw errors. - * @example sheepShearedTest.js - * ```typescript - * test.assertEntityHasComponent("minecraft:sheep", "minecraft:is_sheared", entityLoc, false); - * - * ``` - */ - assertEntityHasComponent( - entityTypeIdentifier: string, - componentIdentifier: string, - blockLocation: BlockLocation, - hasComponent?: boolean - ): void {} - /** - * @remarks - * Depending on the value for isPresent, tests that a - * particular entity is present or not present at the specified - * location. Depending on the value of isPresent, if the entity - * is found or not found, an error is thrown. - * @param entity - * Specific entity to test for. - * @param blockLocation - * Location of the entity to test for. - * @param isPresent - * Whether to test that an entity is present or not present at - * the specified location. - * @throws This function can throw errors. - */ - assertEntityInstancePresent(entity: Entity, blockLocation: BlockLocation, isPresent?: boolean): void {} - /** - * @remarks - * Depending on the value of isPresent, tests for the presence - * or non-presence of entity of a specified type at a - * particular location. If the condition is not met, an - * exception is thrown. - * @param entityTypeIdentifier - * Type of entity to test for (e.g., 'minecraft:skeleton'). If - * an entity namespace is not specified, 'minecraft:' is - * assumed. - * @param blockLocation - * Location of the entity to test for. - * @param isPresent - * If true, this function tests whether an entity of the - * specified type is present. If false, tests that an entity of - * the specified type is not present. - * @throws This function can throw errors. - */ - assertEntityPresent(entityTypeIdentifier: string, blockLocation: BlockLocation, isPresent?: boolean): void {} - /** - * @remarks - * Tests that an entity of a specified type is present within - * the GameTest area. If not, an exception is thrown. - * @param entityTypeIdentifier - * Type of entity to test for (e.g., 'minecraft:skeleton'). If - * an entity namespace is not specified, 'minecraft:' is - * assumed. - * @param isPresent - * If true, this function tests whether an entity of the - * specified type is present in the GameTest area. If false, - * tests that an entity of the specified type is not present. - * @throws This function can throw errors. - */ - assertEntityPresentInArea(entityTypeIdentifier: string, isPresent?: boolean): void {} - /** - * @remarks - * Tests that an entity (e.g., a skeleton) at the specified - * location has a particular piece of data. If not, an error is - * thrown. - * @param blockLocation - * Location of the entity to look for. - * @param entityTypeIdentifier - * Identifier of the entity (e.g., 'minecraft:skeleton') to - * look for. Note if no namespace is specified, 'minecraft:' is - * assumed. - * @param callback - * Callback function where facets of the selected entity can be - * tested for. If this callback function returns false or no - * entity with the specified identifier is found, an exception - * is thrown. - * @throws This function can throw errors. - * @example villagerEffectTest.js - * ```typescript - * test.assertEntityState( - * villagerPos, - * "minecraft:villager_v2", - * (entity) => entity.getEffect(MinecraftEffectTypes.regeneration).duration > 120 - * ); // At least 6 seconds remaining in the villagers' effect - * - * ``` - */ - assertEntityState( - blockLocation: BlockLocation, - entityTypeIdentifier: string, - callback: (arg: Entity) => boolean - ): void {} - /** - * @remarks - * Depending on the value of isTouching, tests that an entity - * of a specified type is touching or connected to another - * entity. If the condition is not met, an exception is thrown. - * @param entityTypeIdentifier - * Type of entity to test for (e.g., 'minecraft:skeleton'). If - * an entity namespace is not specified, 'minecraft:' is - * assumed. - * @param location - * Location of the entity to test for. - * @param isTouching - * If true, this function tests whether the entity is touching - * the specified location. If false, tests that an entity is - * not testing the specified location. - * @throws This function can throw errors. - */ - assertEntityTouching(entityTypeIdentifier: string, location: Location, isTouching?: boolean): void {} - /** - * @remarks - * Depending on the value of isWaterlogged, tests that a block - * at a location contains water. If the condition is not met, - * an error is thrown. Pure water blocks are not considered to - * be waterlogged. - * @param blockLocation - * Location of the block to test for. - * @param isWaterlogged - * Whether to test that the block at _position_ is expected to - * be waterlogged. - * @throws This function can throw errors. - */ - assertIsWaterlogged(blockLocation: BlockLocation, isWaterlogged?: boolean): void {} - /** - * @remarks - * Tests that items of a particular type and count are present - * within an area. If not, an error is thrown. - * @param itemType - * Type of item to look for. - * @param blockLocation - * Location to search around for the specified set of items. - * @param searchDistance - * Range, in blocks, to aggregate a count of items around. If - * 0, will only search the particular block at _position_. - * @param count - * Number of items, at minimum, to look and test for. - * @throws This function can throw errors. - * @example findFeathers.js - * ```typescript - * test.assertItemEntityCountIs(Items.feather, expectedFeatherLoc, 0, 1); - * - * ``` - */ - assertItemEntityCountIs( - itemType: ItemTypeDefinition, - blockLocation: BlockLocation, - searchDistance: number, - count: number - ): void {} - /** - * @remarks - * Depending on the value of isPresent, tests whether a - * particular item entity is present or not at a particular - * location. If the condition is not met, an exception is - * thrown. - * @param itemType - * Type of item to test for. - * @param blockLocation - * Location of the item entity to test for. - * @param searchDistance - * Radius in blocks to look for the item entity. - * @param isPresent - * If true, this function tests whether an item entity of the - * specified type is present. If false, tests that an item - * entity of the specified type is not present. - * @throws This function can throw errors. - */ - assertItemEntityPresent( - itemType: ItemTypeDefinition, - blockLocation: BlockLocation, - searchDistance: number, - isPresent?: boolean - ): void {} - /** - * @remarks - * Tests that Redstone power at a particular location matches a - * particular value. If not, an exception is thrown. - * @param blockLocation - * Location to test. - * @param power - * Expected power level. - * @throws This function can throw errors. - */ - assertRedstonePower(blockLocation: BlockLocation, power: number): void {} - /** - * @remarks - * Marks the current test as a failure case. - * @param errorMessage - * Error message summarizing the failure condition. - * @throws This function can throw errors. - */ - fail(errorMessage: string): void {} - /** - * @remarks - * Runs the given callback. If the callback does not throw an - * exception, the test is marked as a failure. - * @param callback - * Callback function that runs. If the function runs - * successfully, the test is marked as a failure. Typically, - * this function will have .assertXyz method calls within it. - * @throws This function can throw errors. - */ - failIf(callback: () => void): void {} - /** - * @remarks - * Gets a block at the specified block location. - * @param blockLocation - * Location of the block to retrieve. - * @throws This function can throw errors. - */ - getBlock(blockLocation: BlockLocation): Block { - return new Block("air"); - } - /** - * @remarks - * Gets the dimension of this test. - * @throws This function can throw errors. - */ - getDimension(): IDimension { - return new BlockCube(); - } - /** - * @remarks - * If the block at the specified block location is a fence, - * this returns a helper object with details on how a fence is - * connected. - * @param blockLocation - * Location of the block to retrieve. - * @throws This function can throw errors. - */ - getFenceConnectivity(blockLocation: BlockLocation): FenceConnectivity { - return new FenceConnectivity(); - } - /** - * @remarks - * Returns the direction of the current test - see the - * {@link mojang-minecraft}.Direction enum for more information on - * potential values (north, east, south, west - values 2-5). - */ - getTestDirection(): Direction { - return Direction.north; - } - /** - * @remarks - * This asynchronous function will wait for the specified time - * in ticks before continuing execution. - * @param tickDelay - * Amount of time to wait, in ticks. - */ - idle(tickDelay: number): Promise { - return Promise.resolve(); - } - /** - * @remarks - * Kills all entities within the GameTest structure. - * @throws This function can throw errors. - */ - killAllEntities(): void {} - /** - * @remarks - * Presses a button at a block location. - * @param blockLocation - * Location to push the button at. - * @throws - * Will throw an error if a button is not present at the - * specified position. - */ - pressButton(blockLocation: BlockLocation): void {} - /** - * @remarks - * Displays the specified message to all players. - * @param text - * Message to display. - * @throws This function can throw errors. - */ - print(text: string): void {} - /** - * @remarks - * Pulls a lever at a block location. - * @param blockLocation - * Location to pull the lever at. - * @throws - * Will throw an error if a lever is not present at the - * specified position. - */ - pullLever(blockLocation: BlockLocation): void {} - /** - * @remarks - * Sends a Redstone pulse at a particular location by creating - * a temporary Redstone block. - * @param blockLocation - * Location to pulse Redstone at. - * @param duration - * Number of ticks to pulse Redstone. - * @throws This function can throw errors. - */ - pulseRedstone(blockLocation: BlockLocation, duration: number): void {} - /** - * @remarks - * From a BlockLocation, returns a new BlockLocation with - * coordinates relative to the current GameTest structure - * block. For example, the relative coordinates for the block - * above the structure block are (0, 1, 0). Rotation of the - * GameTest structure is also taken into account. - * @param worldBlockLocation - * Absolute location in the world to convert to a relative - * location. - * @returns - * A location relative to the GameTest command block. - * @throws This function can throw errors. - */ - relativeBlockLocation(worldBlockLocation: BlockLocation): BlockLocation { - return new BlockLocation(0, 0, 0); - } - /** - * @remarks - * From a location, returns a new location with coordinates - * relative to the current GameTest structure block. For - * example, the relative coordinates for the block above the - * structure block are (0, 1, 0). Rotation of the GameTest - * structure is also taken into account. - * @param worldLocation - * Absolute location in the world to convert to a relative - * location. - * @returns - * A location relative to the GameTest command block. - * @throws This function can throw errors. - */ - relativeLocation(worldLocation: Location): Location { - return new Location(0, 0, 0); - } - /** - * @remarks - * Removes a simulated player from the world. - * @param simulatedPlayer - * Simulated player to remove. - */ - removeSimulatedPlayer(simulatedPlayer: SimulatedPlayer): void {} - /** - * @remarks - * Returns a relative direction given the current rotation of - * the current test. Passing in Direction.south will return the - * test direction; Passing in Direction.north will return the - * opposite of the test direction, and so on. - * @param direction - * Direction to translate into a direction relative to the - * GameTest facing. Passing in Direction.south will return the - * test direction; Passing in Direction.north will return the - * opposite of the test direction, and so on. - * @throws This function can throw errors. - */ - rotateDirection(direction: Direction): Direction { - return Direction.down; - } - /** - * @remarks - * Runs a specific callback after a specified delay of ticks - * @param delayTicks - * Number of ticks to delay before running the specified - * callback. - * @param callback - * Callback function to execute. - * @throws This function can throw errors. - */ - runAfterDelay(delayTicks: number, callback: () => void): void {} - /** - * @remarks - * Runs the given callback after a delay of _tick_ ticks from - * the start of the GameTest. - * @param tick - * Tick (after the start of the GameTest) to run the callback - * at. - * @param callback - * Callback function to execute. - * @throws This function can throw errors. - */ - runAtTickTime(tick: number, callback: () => void): void {} - /** - * @remarks - * Sets a block to a particular configuration (a - * BlockPermutation) at the specified block location. - * @param blockData - * Permutation that contains the configuration data for a - * block. - * @param blockLocation - * Location of the block to set. - * @throws This function can throw errors. - */ - setBlockPermutation(blockData: BlockPermutation, blockLocation: BlockLocation): void {} - /** - * @remarks - * Sets a block to a particular type at the specified block - * location. - * @param blockType - * Type of block to set. - * @param blockLocation - * Location of the block to set. - * @throws This function can throw errors. - */ - setBlockType(blockType: BlockType, blockLocation: BlockLocation): void {} - /** - * @remarks - * For blocks that are fluid containers - like a cauldron - - * changes the type of fluid within that container. - * @param location - * Location of the fluid container block. - * @param type - * Type of fluid to set. See {@link mojang-gametest}.FluidType for a - * list of values. - * @throws This function can throw errors. - */ - setFluidContainer(location: BlockLocation, type: number): void {} - /** - * @remarks - * Sets the fuse of an explodable entity. - * @param entity - * Entity that is explodable. - * @param fuseLength - * Length of time, in ticks, before the entity explodes. - * @throws This function can throw errors. - */ - setTntFuse(entity: Entity, fuseLength: number): void {} - /** - * @remarks - * Spawns an entity at a location. - * @param entityTypeIdentifier - * Type of entity to create. If no namespace is provided, - * 'minecraft:' is assumed. Note that an optional initial spawn - * event can be specified between less than/greater than signs - * (e.g., namespace:entityType). - * @param blockLocation - * @returns - * The spawned entity. If the entity cannot be spawned, returns - * undefined. - * @throws This function can throw errors. - * @example spawnAdultPig.js - * ```typescript - * test.spawn("minecraft:pig", new BlockLocation(1, 2, 1)); - * - * ``` - */ - spawn(entityTypeIdentifier: string, blockLocation: BlockLocation): Entity { - return new Entity(); - } - /** - * @remarks - * Spawns an entity at a location. - * @param entityTypeIdentifier - * Type of entity to create. If no namespace is provided, - * 'minecraft:' is assumed. Note that an optional initial spawn - * event can be specified between less than/greater than signs - * (e.g., namespace:entityType). - * @param location - * @returns - * The spawned entity. If the entity cannot be spawned, returns - * undefined. - * @throws This function can throw errors. - * @example spawnAdultPig.js - * ```typescript - * test.spawn("minecraft:pig", new Location(1.5, 2, 1.5)); - * ``` - */ - spawnAtLocation(entityTypeIdentifier: string, location: Location): Entity { - return new Entity(); - } - /** - * @remarks - * Spawns an item entity at a specified location. - * @param itemStack - * ItemStack that describes the item entity to create. - * @param location - * Location to create the item entity at. - * @throws This function can throw errors. - * @example spawnEmeralds.js - * ```typescript - * const oneEmerald = new ItemStack(MinecraftItemTypes.emerald, 1, 0); - * const fiveEmeralds = new ItemStack(MinecraftItemTypes.emerald, 5, 0); - * - * test.spawnItem(oneEmerald, new Location(3.5, 3, 1.5)); - * test.spawnItem(fiveEmeralds, new Location(1.5, 3, 1.5)); - * - * ``` - */ - spawnItem(itemStack: ItemStack, location: Location): Entity { - return new Entity(); - } - /** - * @remarks - * Creates a new simulated player within the world. - * @param blockLocation - * Location where to spawn the simulated player. - * @param name - * Name to give the new simulated player. - * @param gameMode - * @throws This function can throw errors. - */ - spawnSimulatedPlayer(blockLocation: BlockLocation, name?: string, gameMode?: GameMode): SimulatedPlayer { - return new SimulatedPlayer(); - } - /** - * @remarks - * Spawns an entity at a location without any AI behaviors. - * This method is frequently used in conjunction with methods - * like .walkTo to create predictable mob actions. - * @param entityTypeIdentifier - * @param blockLocation - * Location where the entity should be spawned. - * @throws This function can throw errors. - */ - spawnWithoutBehaviors(entityTypeIdentifier: string, blockLocation: BlockLocation): Entity { - return new Entity(); - } - /** - * @remarks - * Spawns an entity at a location without any AI behaviors. - * This method is frequently used in conjunction with methods - * like .walkTo to create predictable mob actions. - * @param entityTypeIdentifier - * @param location - * Location where the entity should be spawned. - * @throws This function can throw errors. - */ - spawnWithoutBehaviorsAtLocation(entityTypeIdentifier: string, location: Location): Entity { - return new Entity(); - } - /** - * @remarks - * Tests that a particular item entity is present at a - * particular location. If not, an exception is thrown. - * @param blockLocation - * BlockLocation containing a multiface block. - * @param fromFace - * Face to spread from. This face must already be set. - * @param direction - * Direction to spread. Use the Minecraft.Direction enum to - * specify a direction. - * @throws This function can throw errors. - * @example spreadFromFaceTowardDirection.js - * ```typescript - * test.spreadFromFaceTowardDirection(new BlockLocation(1, 2, 1), Direction.south, Direction.down); - * ``` - */ - spreadFromFaceTowardDirection(blockLocation: BlockLocation, fromFace: Direction, direction: Direction): void {} - - /** - * @remarks - * Marks the current test as a success case. - * @throws This function can throw errors. - */ - succeed(): void {} - /** - * @remarks - * Runs the given callback. If the callback does not throw an - * exception, the test is marked as a success. - * @param callback - * Callback function that runs. If the function runs - * successfully, the test is marked as a success. Typically, - * this function will have .assertXyz method calls within it. - * @throws This function can throw errors. - */ - succeedIf(callback: () => void): void {} - /** - * @remarks - * Marks the test as a success at the specified tick. - * @param tick - * Tick after the start of the GameTest to mark the test as - * successful. - * @throws This function can throw errors. - */ - succeedOnTick(tick: number): void {} - /** - * @remarks - * Runs the given callback at _tick_ ticks after the start of - * the test. If the callback does not throw an exception, the - * test is marked as a failure. - * @param tick - * Tick after the start of the GameTest to run the testing - * callback at. - * @param callback - * Callback function that runs. If the function runs - * successfully, the test is marked as a success. - * @throws This function can throw errors. - */ - succeedOnTickWhen(tick: number, callback: () => void): void {} - /** - * @remarks - * Runs the given callback every tick. When the callback - * successfully executes, the test is marked as a success. - * Specifically, the test will succeed when the callback does - * not throw an exception. - * @param callback - * Testing callback function that runs. If the function runs - * successfully, the test is marked as a success. - * @throws This function can throw errors. - */ - succeedWhen(callback: () => void): void {} - /** - * @remarks - * Depending on the condition of isPresent, tests for the - * presence of a block of a particular type on every tick. When - * the specified block of a type is found or not found - * (depending on isPresent), the test is marked as a success. - * @param blockType - * Type of block to test for. - * @param blockLocation - * Location of the block to test at. - * @param isPresent - * If true, this function tests whether a block of the - * specified type is present. If false, tests that a block of - * the specified type is not present. - * @throws This function can throw errors. - */ - succeedWhenBlockPresent(blockType: BlockType, blockLocation: BlockLocation, isPresent?: boolean): void {} - /** - * @remarks - * Tests for the presence of a component on every tick. - * Depending on the value of hasComponent, when the specified - * component is found, the test is marked as a success. - * @param entityTypeIdentifier - * Type of entity to look for. If no namespace is specified, - * 'minecraft:' is assumed. - * @param componentIdentifier - * Type of component to test for the presence of. If no - * namespace is specified, 'minecraft:' is assumed. - * @param blockLocation - * Block location of the entity to test. - * @param hasComponent - * If true, this function tests for the presence of a - * component. If false, this function tests for the lack of a - * component. - * @throws This function can throw errors. - */ - succeedWhenEntityHasComponent( - entityTypeIdentifier: string, - componentIdentifier: string, - blockLocation: BlockLocation, - hasComponent: boolean - ): void {} - /** - * @remarks - * Depending on the value of isPresent, tests for the presence - * of an entity on every tick. When an entity of the specified - * type is found or not found (depending on isPresent), the - * test is marked as a success. - * @param entityTypeIdentifier - * Type of entity to test for (e.g., 'minecraft:skeleton'). If - * an entity namespace is not specified, 'minecraft:' is - * assumed. - * @param blockLocation - * Location of the entity to test for. - * @param isPresent - * If true, this function tests whether an entity of the - * specified type is present. If false, tests that an entity of - * the specified type is not present. - * @throws This function can throw errors. - */ - succeedWhenEntityPresent(entityTypeIdentifier: string, blockLocation: BlockLocation, isPresent?: boolean): void {} - /** - * @remarks - * Triggers a block event from a fixed list of available block - * events. - * @param blockLocation - * @param event - * Event to trigger. Valid values include minecraft:drip, - * minecraft:grow_stalagtite, minecraft:grow_stalagmite, - * minecraft:grow_up, minecraft:grow_down and - * minecraft:grow_sideways. - * @param eventParameters - * @throws This function can throw errors. - */ - triggerInternalBlockEvent(blockLocation: BlockLocation, event: string, eventParameters?: number[]): void {} - /** - * @remarks - * This asynchronous function will wait until the code in the - * specified callback successfully completes. until can be used - * in conjunction with .assert functions to evaluate that a - * condition is true. - * @param callback - * Function with code to evaluate. - */ - until(callback: () => void): Promise { - return Promise.resolve(); - } - /** - * @remarks - * Forces a mob to walk to a particular location. Usually used - * in conjunction with methods like .spawnWithoutBehaviors to - * have more predictable mob behaviors. Mobs will stop - * navigation as soon as they intersect the target location. - * @param mob - * Mob entity to give orders to. - * @param blockLocation - * Location where the entity should be walk to. - * @param speedModifier - * Adjustable modifier to the mob's walking speed. - * @throws This function can throw errors. - */ - walkTo(mob: Entity, blockLocation: BlockLocation, speedModifier: number): void {} - /** - * @remarks - * Forces a mob to walk to a particular location. Usually used - * in conjunction with methods like .spawnWithoutBehaviors to - * have more predictable mob behaviors. Mobs will stop - * navigation as soon as they intersect the target location. - * @param mob - * Mob entity to give orders to. - * @param location - * Location where the entity should be walk to. - * @param speedModifier - * Adjustable modifier to the mob's walking speed. - * @throws This function can throw errors. - */ - walkToLocation(mob: Entity, location: Location, speedModifier: number): void {} - /** - * @remarks - * From a BlockLocation with coordinates relative to the - * GameTest structure block, returns a new BlockLocation with - * coordinates relative to world. Rotation of the GameTest - * structure is also taken into account. - * @param relativeBlockLocation - * Location relative to the GameTest command block. - * @returns - * An absolute location relative to the GameTest command block. - * @throws This function can throw errors. - */ - worldBlockLocation(relativeBlockLocation: BlockLocation): BlockLocation { - return new BlockLocation(1, 1, 1); - } - /** - * @remarks - * From a location with coordinates relative to the GameTest - * structure block, returns a new location with coordinates - * relative to world. Rotation of the GameTest structure is - * also taken into account. - * @param relativeLocation - * Location relative to the GameTest command block. - * @returns - * An absolute location relative to the GameTest command block. - * @throws This function can throw errors. - */ - worldLocation(relativeLocation: Location): Location { - return new Location(1, 1, 1); - } -} diff --git a/app/src/images/bedrock.png b/app/src/images/bedrock.png deleted file mode 100644 index e2df190e41289cff16fdc099cc4ac6edd2e5c30e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 278 zcmV+x0qOpUP)Px#z)3_wR5;6pliLl&APhq@3oCRO24E=0?Uj*Som#2x zM-&>skC4_{>%Ok*6?4ve?|o~}Yh~^`mlisx@FiyLE4wzvc!3-M7jx~)zTmJT0T$(2 zvOsu{^3!UW(M);3Yg;1OV}bJcOni|F~*U+j$Pn5c$q z`Ml>DIYilQf|8ZfTkLRJNP8qxJWZsuluLE(Am!|H5_y>Yp^D-NcN5rIc`4|Arfil$ cavoIs0YYK^Y6BD#l>h($07*qoM6N<$f;!c9*#H0l diff --git a/app/src/images/coarse_dirt.png b/app/src/images/coarse_dirt.png deleted file mode 100644 index 39211f1208d709dd3d255863226f4683eff5f6b4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 609 zcmV-n0-pVeP)Px%3rR#lR5;6BQ%z4(Q4qbq!i2Dpj|en@QnBzTZTaX& zS`le!A5=?I0uLyGil9_sQDPJ+#Epq!+$tMZuru=OhIm z`RbV*l%n#cFe=)qg6i3P+sw+W?cmt9{dFTF^JBdXE?EG5H2tKD^y>9GeaMRi+HV2& z-H4Qn*Ohn0Q9eKnhVz%zwEX#0mhIy_YAE3EK|0joFA6H^4*Y8u`$hSCw8(CeM+(}ea=vUX$U-b2x}llJo#d}~Ji=08 z^qc~?{m<*yUS6P0H5nAo^XNM)kCPI2#QK#6DPYd3Eckz@Ot9ixJ3eRwKLAxk=mIKO zG^69l4s|i9oC@FT26K0M+T^NPVj-Ov-cSRrJQMC_02`=(9$Lg`e>d{HpL$7(r@C>B v3b37X=xEqBQMJ`-(XYR?>ZFwucY53ae)Px#(Md!>R5;6ZlCcd!F$_e#4l5whQPCrT#0V*A7y$hZ z*oEmp7wMw+@8=g*65BcZ&aUtK@%yw(x7YR9ZRWe54y(A&(nX0((0f^y;WHrbipk1o zuEIB~F^732wAR{iu$!ckT?_yR70_pLC!h+YuiREva;wya_aS0(lz2>_;-u-bGC9ZR zZf5=tkWQX%IX^Qt-Gk(wyh){UJmhR(`$@%G)r=P_Xmq5&G51YOXM*gRyIN6@J#XiY taHcWa(8?q#O#WGD1CTplk@n{A0)O^}D66O1i$DMX002ovPDHLkV1i?sfdl{m diff --git a/app/src/images/mcc_g.png b/app/src/images/mcc_g.png deleted file mode 100644 index d5cfba34c1284c61696d98ac22402bc08777772d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7441 zcmeHM4K&p08XwZKk=)&TLb*|EQ+M0YB%)~)mQoW+A{nBYqKjzA=U+@iDVXu zNxqtVL=3BZG&Hr18Pph?G}{bKXc}hBy!St2w}Z~Pd+Thw?LEEcFz@^P-~aPG@7M4B zJ2rU%^LP~-3p?7(U?WSGFyoTAP#d<8=PrTEd&Mwor z^n;<@yy}(vR2E;`uN}Vp#~`(uc`fyUvBwM0-Y#=T7au)QSAIIMae0EHo6=$z!%Jrx zYaEuHk0!1^bIau_iq%&y=-9YGBNP*E7W(udk~`F}Xx)X*bhlB@!_^O?N;;EESo|&% zjWiGQI~J*;usXIKzoiI28hi2X9fi9)F7TTS)ew621#ZW!9+whh7w~$byL*S4#<>~p;J8B{wBDTuLJS4q z$FiKxTLQ-;bID`CuW5iIrf)W+LoO`9&*}k>`-h;f6NSLe6g+z(q3dM{&?1WLh8`0w z(FHW0Nx0E$dLEz!YqY!%4;ym5lFsGUYoP+!D}+8VM&k)TH!*yl=3K@s^UvNF_`EMG z(wPAgoPdN3vMq$von6Va?TK|e(=w4VD_x*xgCg1ltO;!rP+wXV;~!|}S?Yl7HGH&I zyTsVYQHsszmSV+Sl+5v%m8Av*8EMtA$-Tfm>B+`8oY02lsIc;`R19yvXiPmW}SL=RJ#u_OmXBL#+zQ_&?zh7(GTOW<*-M;bg?xEEIEu=!+xhuLN59HPq ziV>mKOqf>$)GNHo+=LS&HH3T>7LX7kO@xoLtC4!PC?b{-IuXnN<`5m1XU-q*WB5Il zxwabZ9OJ!;VeuoV>aieZSK+Pj^g_a|PScuejHrnts0($>)C!Lhueyk_r*$QZ3wQ$$ zT_v)f+KxT!)-qmfY;Ub|JR1203*v2*l|1K?JhV0QT6&tlyb1(Xbn16G;V1aJSp9fm zwXBGcejbEhiPEi;HHTa(9d!LiRDRBJ{i^3)niIM&)`U(Z*Ju*34OkX;LCNC59txgX zUsE$41>+<)WM5(RWv^^kDzK}k@+H{?hkDYTT=um=bjIWz``nq3*1)h6QjHI0EWzPMxCe3c|u^E>e` zHeYJc`cl1A8^7=?u?l3+vb6+|S0xFHxoch}w85yH34#yuAZjhH0-JOtAgr!3bG?w7 zHi2&aUM4CIz}cvrM+xql`@u29kx&vrXEoq^ub{!?kNLm+eshHw`5<84Ayb= zO=S8lXdi3G6qp#QbPHX&qj>d6G;FHPLJa0B?34dQKzxuYRzW+BGZ99mK3+R~{DSLT-3 zrznS{9H|)f(n%{P2R~)r$5Z=!oGfs%0h+ z1%y&;8^EJ>0ajel0K`&9w2)+@P6B2A+0u$iUqc`(D0SnB=~0A80?#g@K9#hs(}Ktu zbOqqFHA3^B6LapXJEM(lX+I?#T+j2m9H=HI5nf3KJ9(3ZYAXGHbLr5e!NE-ou#pK_ zd?KV`_aXV{#vwAWUNEK)qg#Rg$&g?L$6%t@uTVS}P_?E_BQTnc_kpyq6Um(g7LlKoQe;N5kP${VUr58wvHX zUWILD3;Af8;w79^^%sgiCxUn5rktG^JEDlMsPIvg^L(+9YJpt&Q>pe3j8HgKIkC5l z#cej3%p;_C!!$#RUm6V}+;4)_iDG&#OhhJS3BFE%6rO)kY1(+!Z^m zCkAoEzsyDV=HY(-1nTuda(XRNZ2}Y&?!`a;Hj^yCo&FSd_u4r{<@cvuEI&%mqq2c5 zkMGND!OOFo@?lY$58aLwV1_nOMI`$T!_RyVShs!n$tF`m|DJwpIDEC}xo zRsG*9qM?~8<22u0;Y>}4KRz8Wl??Pv9vGLvNxo`AX2l{by6nMi2F+z)2$Mpop_Y{P z)MA3R*T)J4i##Ya6AcL?UUfM8X})FHP9!a?E~Y!n**_aaeo#V&V^M6X{9>yeg;Ri+ zn4lJiCvL8%&AbI3;l=)8MHw zxd+HU)gjK^5gQeDjH~u{e<)b)Su9U$oJ{wfoFjMem%{n)fl=eouh9(x(YRmnv8WXO z^5+}yL%XSL8e@wKS_T8ML7e`{=?R-N@ILRiyg7P@s^r~8)Hyn6{YY+hiyg+cbhCH- Fe*ihQ&Itej diff --git a/app/src/images/mccb_pattern_green_corner_top_03.png b/app/src/images/mccb_pattern_green_corner_top_03.png deleted file mode 100644 index 36dfb925ca7c7023899f4a569dadab7fb7d46b57..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1556 zcmeAS@N?(olHy`uVBq!ia0y~y;H(C+131`#q|-waejvqI9OUlAuxibaxvL9F7x#kq(A)v=*oLnM!!)SwjcjF2%r%Q`m zIi_(d7ayzq{H*f9ywnRj{d;~F+sW^kb3gy%jOuUk@2+rrZ(a;?I~X*?Wq;y?aUA+P z_rll=Oaj%6Fb<2tHzpXH!{H6c4`3kBaDyAhR$$mD4r4noBZ!P&m}TU9c`w`XTXA77sN>Q6SzgofqK`3Z34 zboQ#<#+sBV&y)DCUtj&OV8(VMY5w-Bui~5cOr3qpa^^iF{Z_SQvsTS~@k1HzTDjHy zy6@u86mPtH-uJw}U+(Oa*%P<^ZjRo+_Re3W^+(h0SNuG@Yo*$!sFbe(lzz@0s~L>1F=fWshf;F~gMIm^G^g9@`g^DTzsnlFF5z zZ&IFJxz~T`W7Y1dm4)}`y=-2;_ft(=cdX_Auj>!@o(+tH$J(|f8;ZKEH4E z+iNHLird$(e<}&{QiAuVd>Odn0ZiF;waM>3+mwI&xbyJ!{ilm3E*9rIv;1+^?$S+< zPk*nA0E(0>|9<&n)^5??hIe1)%!9kRYH8i?QwIa*?XLL#Df)i>wC76gV&Cm&_f5aG zcJlmvmY=$|4(^m682{5 zI~7EZu3C9g9j2PWRt+IRhphhdcmLL`Im^%gdt2)*2XjQjzE$adZ)49Ci%-w5`}F&K y<-55h%adPPT*y0`x70fJj4@0h-RT4MD^|JdOyH69yd7u+vfb0w&t;ucLK6TggOywW diff --git a/app/src/local/IAuthenticationToken.ts b/app/src/local/IAuthenticationToken.ts index 8a9613c2..1a57370a 100644 --- a/app/src/local/IAuthenticationToken.ts +++ b/app/src/local/IAuthenticationToken.ts @@ -1,7 +1,4 @@ -import { ServerPermissionLevel } from "./MinecraftHttpServer"; - export interface IAuthenticationToken { time: number; code: string; - permissionLevel: ServerPermissionLevel; } diff --git a/app/src/minecraft/Database.ts b/app/src/minecraft/Database.ts index a1e71e0a..46dca8f2 100644 --- a/app/src/minecraft/Database.ts +++ b/app/src/minecraft/Database.ts @@ -33,7 +33,7 @@ export default class Database { static latestVersion: string | undefined = undefined; static latestPreviewVersion: string | undefined = undefined; - static dataPath: string = "res/latest/van/"; + static dataPath: string = "res/latest/"; static minecraftModuleNames = [ "@minecraft/server-gametest", diff --git a/app/src/script/AutoScriptManager.ts b/app/src/script/AutoScriptManager.ts deleted file mode 100644 index dd5bd16c..00000000 --- a/app/src/script/AutoScriptManager.ts +++ /dev/null @@ -1,156 +0,0 @@ -import IFile from "../storage/IFile"; -import { EventDispatcher, IEventHandler } from "ste-events"; -import IAutoScriptData from "./../autoscript/IAutoScriptData"; -import AutoScript from "./../autoscript/AutoScript"; -import StorageUtilities from "../storage/StorageUtilities"; - -export default class AutoScriptManager { - private _jsonFile?: IFile; - private _jsFile?: IFile; - private _functionFile?: IFile; - private _isLoaded: boolean; - private _autoScript?: AutoScript; - - private _autoScriptData?: IAutoScriptData; - - get autoScript() { - return this._autoScript; - } - - private _onLoaded = new EventDispatcher(); - - constructor() { - this._isLoaded = false; - } - - public get isLoaded() { - return this._isLoaded; - } - - public get jsonFile() { - return this._jsonFile; - } - - public get onLoaded() { - return this._onLoaded.asEvent(); - } - - public get name() { - if (this._autoScriptData === undefined) { - return ""; - } - - return this._autoScriptData.name; - } - - public set name(newName: string) { - if (this._autoScriptData === undefined) { - return; - } - - this._autoScriptData.name = newName; - } - - public set jsonFile(newFile: IFile | undefined) { - this._jsonFile = newFile; - } - - public async load() { - if (this._jsonFile === undefined || this._isLoaded) { - return; - } - - await this._jsonFile.loadContent(); - - if (this._jsonFile.content === null || this._jsonFile.content instanceof Uint8Array) { - return; - } - - this._autoScriptData = StorageUtilities.getJsonObject(this._jsonFile); - - if (this._autoScriptData) { - this._autoScript = new AutoScript(this._autoScriptData); - - this._autoScript.ensureLoaded(); - this._autoScript.name = StorageUtilities.getBaseFromName(this._jsonFile.name); - } - - this._isLoaded = true; - this._onLoaded.dispatch(this, this); - } - - private ensureJsFile() { - if (this._jsonFile === undefined || this._jsFile !== undefined) { - return; - } - - const newFileName = StorageUtilities.getBaseFromName(this._jsonFile.name) + ".js"; - - this._jsFile = this._jsonFile.parentFolder.ensureFile(newFileName); - } - - private async ensureFunctionFile() { - if (this._jsonFile === undefined || this._functionFile !== undefined) { - return; - } - - const newFileName = StorageUtilities.getBaseFromName(this._jsonFile.name) + ".mcfunction"; - - let functionFolder = this._jsonFile.parentFolder; - - if (functionFolder.name === "scripts" && functionFolder.parentFolder) { - functionFolder = functionFolder.parentFolder.ensureFolder("functions"); - } - - await functionFolder.ensureExists(); - - this._functionFile = functionFolder.ensureFile(newFileName); - } - - async persist() { - if (this._jsonFile === undefined) { - return; - } - - const bpString = JSON.stringify(this._autoScriptData); - - this._jsonFile.setContent(bpString); - - this.ensureJsFile(); - await this.ensureFunctionFile(); - - if (this.autoScript && this._jsFile) { - const jsString = this.autoScript.generateJavaScript(); - this._jsFile.setContent(jsString); - } - - if (this.autoScript && this._functionFile) { - const functionContent = await this.autoScript.generateMCFunction(); - this._functionFile.setContent(functionContent); - } - } - - static async ensureAutoScriptOnFile(file: IFile, loadHandler?: IEventHandler) { - let autos: AutoScriptManager | undefined = undefined; - - if (file.manager === undefined) { - autos = new AutoScriptManager(); - - autos.jsonFile = file; - - file.manager = autos; - } - - if (file.manager !== undefined && file.manager instanceof AutoScriptManager) { - autos = file.manager as AutoScriptManager; - - if (!autos.isLoaded && loadHandler) { - autos.onLoaded.subscribe(loadHandler); - } - - await autos.load(); - } - - return autos; - } -} diff --git a/app/src/script/WorldTestManager.ts b/app/src/script/WorldTestManager.ts deleted file mode 100644 index c92db1ef..00000000 --- a/app/src/script/WorldTestManager.ts +++ /dev/null @@ -1,226 +0,0 @@ -import IFile from "../storage/IFile"; -import Log from "../core/Log"; -import { EventDispatcher, IEventHandler } from "ste-events"; -import IWorldTestDefinition from "../worldtest/IWorldTestDefinition"; -import WorldTest from "./../worldtest/WorldTest"; -import StorageUtilities from "../storage/StorageUtilities"; -import Project from "./../app/Project"; -import Structure from "../minecraft/Structure"; -import BlockCube from "../minecraft/BlockCube"; -import BlockLocation from "../minecraft/BlockLocation"; -import Utilities from "../core/Utilities"; - -export default class WorldTestManager { - private _jsonFile?: IFile; - private _jsFile?: IFile; - private _functionFile?: IFile; - private _structureFile?: IFile; - private _isLoaded: boolean; - private _worldTest?: WorldTest; - private _worldTestData?: IWorldTestDefinition; - - get worldTest() { - return this._worldTest; - } - - private _onLoaded = new EventDispatcher(); - - constructor() { - this._isLoaded = false; - } - - public get isLoaded() { - return this._isLoaded; - } - - public get jsonFile() { - return this._jsonFile; - } - - public get onLoaded() { - return this._onLoaded.asEvent(); - } - - public get name() { - if (this._worldTestData === undefined) { - return ""; - } - - return this._worldTestData.name; - } - - public set name(newName: string) { - if (this._worldTestData === undefined) { - return; - } - - this._worldTestData.name = newName; - } - - public set jsonFile(newFile: IFile | undefined) { - this._jsonFile = newFile; - } - - public async load() { - if (this._jsonFile === undefined || this._isLoaded) { - return; - } - - await this._jsonFile.loadContent(); - - if (!this._jsonFile.content || this._jsonFile.content instanceof Uint8Array) { - return; - } - - try { - const data: any = JSON.parse(this._jsonFile.content); - - this._worldTestData = data; - - if (data) { - this._worldTest = new WorldTest(data); - - this._worldTest.ensureLoaded(); - this._worldTest.name = StorageUtilities.getBaseFromName(this._jsonFile.name); - } - } catch (e) { - Log.fail("Could not parse world test JSON " + e); - } - - this._isLoaded = true; - this._onLoaded.dispatch(this, this); - } - - private async ensureFunctionFile() { - if (this._jsonFile === undefined || this._functionFile !== undefined) { - return; - } - - const newFileName = StorageUtilities.getBaseFromName(this._jsonFile.name) + ".mcfunction"; - - let functionFolder = this._jsonFile.parentFolder; - - if (functionFolder.name === "scripts" && functionFolder.parentFolder) { - functionFolder = functionFolder.parentFolder.ensureFolder("functions"); - } - - await functionFolder.ensureExists(); - - this._functionFile = functionFolder.ensureFile(newFileName); - } - - async persist() { - if (this._jsonFile === undefined || this._worldTest === undefined) { - return; - } - - const bpString = JSON.stringify(this._worldTest.data, null, 2); - - this._jsonFile.setContent(bpString); - - this.ensureFunctionFile(); - } - - async persistSideFiles(project: Project) { - if (!project.defaultBehaviorPackFolder || this._jsonFile === undefined) { - Log.unexpectedUndefined("WTM"); - return; - } - - if (this._jsFile === undefined) { - const scriptsFolder = project.defaultBehaviorPackFolder.ensureFolder("scripts"); - - await scriptsFolder.ensureExists(); - - const newFileName = StorageUtilities.getBaseFromName(this._jsonFile.name) + ".gen.js"; - - this._jsFile = scriptsFolder.ensureFile(newFileName); - } - - if (this._structureFile === undefined) { - const structuresFolder = project.defaultBehaviorPackFolder.ensureFolder("structures"); - - await structuresFolder.ensureExists(); - - const structuresSubFolder = structuresFolder.ensureFolder("gametest"); - - await structuresSubFolder.ensureExists(); - - const newFileName = StorageUtilities.getBaseFromName(this._jsonFile.name) + "empty.mcstructure"; - - this._structureFile = structuresSubFolder.ensureFile(newFileName); - } - - if (this.worldTest && this._jsFile) { - const jsString = this.worldTest.generateGameTestJavaScript(this._jsonFile.name); - this._jsFile.setContent(jsString); - } - - if (this.worldTest) { - const functionsFolder = project.defaultBehaviorPackFolder.ensureFolder("functions"); - - await functionsFolder.ensureExists(); - - for (let i = 0; i < this.worldTest.areas.length; i++) { - const area = this.worldTest.areas[i]; - - for (let j = 0; j < area.scripts.length; j++) { - const script = area.scripts[j]; - - const functionFile = functionsFolder.ensureFile( - Utilities.getSimpleString(area.title + (i + 1).toString() + script.name + (j + 1).toString()) + - ".mcfunction" - ); - - const functionString = "tp " + area.location.x + " " + area.location.y + " " + area.location.z; - /*"\r\ngametest run " + - Utilities.getSimpleString(area.title) + - ":" + - Utilities.getSimpleString(script.name + (j + 1).toString());*/ - - functionFile.setContent(functionString); - } - } - } - - if (this.worldTest && this._structureFile) { - const structure = new Structure(); - const cube = new BlockCube(); - - cube.setMaxDimensions(8, 8, 8); - - structure.cube = cube; - - cube.getBlock(new BlockLocation(0, 0, 0)).typeName = "minecraft:dirt"; - - const bytes = structure.getMCStructureBytes(); - - if (bytes) { - this._structureFile.setContent(bytes); - } - } - } - - static async ensureWorldTestOnFile(file: IFile, loadHandler?: IEventHandler) { - let wtm = undefined; - if (file.manager === undefined) { - const wtm = new WorldTestManager(); - - wtm.jsonFile = file; - - file.manager = wtm; - } - - if (file.manager !== undefined && file.manager instanceof WorldTestManager) { - wtm = file.manager as WorldTestManager; - - if (!wtm.isLoaded && loadHandler) { - wtm.onLoaded.subscribe(loadHandler); - } - - await wtm.load(); - } - - return wtm; - } -} diff --git a/app/src/test/CartoTest.ts b/app/src/test/CartoTest.ts index 239aa99f..2e57e037 100644 --- a/app/src/test/CartoTest.ts +++ b/app/src/test/CartoTest.ts @@ -6,7 +6,8 @@ import Status from "../app/Status"; import NodeStorage from "../local/NodeStorage"; import Database from "../minecraft/Database"; import LocalEnvironment from "../local/LocalEnvironment"; -import ProjectInfoSet, { ProjectInfoSuite } from "../info/ProjectInfoSet"; +import ProjectInfoSet from "../info/ProjectInfoSet"; +import { ProjectInfoSuite } from "../info/IProjectInfoData"; import IFolder from "../storage/IFolder"; import StorageUtilities from "../storage/StorageUtilities"; import ProjectExporter from "../app/ProjectExporter"; diff --git a/app/src/test/CommandLineTest.ts b/app/src/test/CommandLineTest.ts deleted file mode 100644 index 6c5d6bc2..00000000 --- a/app/src/test/CommandLineTest.ts +++ /dev/null @@ -1,262 +0,0 @@ -import { assert } from "chai"; -import Carto from "../app/Carto"; -import Project, { ProjectAutoDeploymentMode } from "../app/Project"; -import CartoApp, { HostType } from "../app/CartoApp"; -import NodeStorage from "../local/NodeStorage"; -import Database from "../minecraft/Database"; -import LocalEnvironment from "../local/LocalEnvironment"; -import IFolder from "../storage/IFolder"; -import StorageUtilities from "../storage/StorageUtilities"; -import { spawn } from "child_process"; -import { chunksToLinesAsync } from "@rauschma/stringio"; -import { Readable } from "stream"; -import * as fs from "fs"; - -CartoApp.hostType = HostType.testLocal; - -let carto: Carto | undefined = undefined; -let localEnv: LocalEnvironment | undefined = undefined; - -let scenariosFolder: IFolder | undefined = undefined; - -let resultsFolder: IFolder | undefined = undefined; - -localEnv = new LocalEnvironment(false); - -(async () => { - CartoApp.localFolderExists = _localFolderExists; - CartoApp.ensureLocalFolder = _ensureLocalFolder; - - const testRootPath = NodeStorage.ensureEndsWithDelimiter(__dirname) + "/../../test/"; - - const scenariosStorage = new NodeStorage(testRootPath, "scenarios"); - - scenariosFolder = scenariosStorage.rootFolder; - - await scenariosFolder.ensureExists(); - - const resultsStorage = new NodeStorage(testRootPath, "results"); - - resultsFolder = resultsStorage.rootFolder; - - await resultsFolder.ensureExists(); - - CartoApp.prefsStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "prefs" + NodeStorage.folderDelimiter, - "" - ); - - CartoApp.projectsStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "projects" + NodeStorage.folderDelimiter, - "" - ); - - CartoApp.packStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "packs" + NodeStorage.folderDelimiter, - "" - ); - - CartoApp.worldStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "worlds" + NodeStorage.folderDelimiter, - "" - ); - - CartoApp.deploymentStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "deployment" + NodeStorage.folderDelimiter, - "" - ); - CartoApp.workingStorage = new NodeStorage( - localEnv.utilities.testWorkingPath + "working" + NodeStorage.folderDelimiter, - "" - ); - - const coreStorage = new NodeStorage(__dirname + "/../../public/data/content/", ""); - Database.contentFolder = coreStorage.rootFolder; - - await CartoApp.init(); // carto app init does something here that, if removed, causes these tests to fail. - - run(); -})(); - -function _ensureLocalFolder(path: string) { - const ls = new NodeStorage(path, ""); - - return ls.rootFolder; -} - -async function _localFolderExists(path: string) { - const ls = new NodeStorage(path, ""); - - return await ls.rootFolder.exists(); -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -async function _loadProject(name: string) { - if (!carto || !scenariosFolder || !resultsFolder) { - assert.fail("Not properly initialized"); - } - - const project = new Project(carto, name, null); - - project.autoDeploymentMode = ProjectAutoDeploymentMode.noAutoDeployment; - project.localFolderPath = __dirname + "/../../../tests/" + name + "/"; - - await project.loadFolderStructure(); - await project.inferProjectItemsFromFiles(); - - return project; -} - -function removeResultFolder(scenarioName: string) { - if (resultsFolder) { - const path = - StorageUtilities.ensureEndsWithDelimiter(resultsFolder.fullPath) + - StorageUtilities.ensureEndsWithDelimiter(scenarioName); - if (fs.existsSync(path)) - // @ts-ignore - fs.rmSync(path, { - recursive: true, - }); - } -} - -describe("worldCommand", async () => { - let exitCode: number | null = null; - const stdoutLines: string[] = []; - const stderrLines: string[] = []; - - before((done) => { - removeResultFolder("worldCommand"); - - const process = spawn("node", [ - " ./../toolbuild/jsn/cli", - "world", - "set", - "-betaapis", - "-o", - "./test/results/worldCommand/", - ]); - - collectLines(process.stdout, stdoutLines); - collectLines(process.stderr, stderrLines); - - process.on("exit", (code) => { - exitCode = code; - done(); - }); - }); - - it("should have no stderr lines", async () => { - assert.equal(stderrLines.length, 0, "Error: |" + stderrLines.join("\n") + "|"); - }).timeout(10000); - - it("exit code should be zero", async () => { - assert.equal(exitCode, 0); - }).timeout(10000); - - it("output matches", async () => { - await folderMatches("worldCommand"); - }); -}); - -describe("deployCommand", async () => { - let exitCode: number | null = null; - const stdoutLines: string[] = []; - const stderrLines: string[] = []; - - before((done) => { - removeResultFolder("deployCommand"); - - const process = spawn("node", [ - " ./../toolbuild/jsn/cli", - "deploy", - "folder", - "-i", - "./../tests/simple/", - "-o", - "./test/results/deployCommand/", - ]); - - collectLines(process.stdout, stdoutLines); - collectLines(process.stderr, stderrLines); - - process.on("exit", (code) => { - exitCode = code; - done(); - }); - }); - - it("should have no stderr lines", async () => { - assert.equal(stderrLines.length, 0, "Error: |" + stderrLines.join("\n") + "|"); - }); - - it("exit code should be zero", async () => { - assert.equal(exitCode, 0); - }); - - it("output matches", async () => { - await folderMatches("deployCommand"); - }); -}); - -async function collectLines(readable: Readable, data: string[]) { - for await (const line of chunksToLinesAsync(readable)) { - if (line !== undefined && line.length >= 0) { - let lineUp = line.replace("\n", ""); - lineUp = lineUp.replace("\r", ""); - - if (lineUp.indexOf("ebugger") <= 0) { - // ignore any lines about the debugger. - console.log(lineUp); - data.push(lineUp); - } - } - } -} - -async function folderMatches(scenarioName: string, excludeList?: string[]) { - if (!scenariosFolder || !resultsFolder) { - assert.fail("Not properly initialized"); - } - - const scenarioOutFolder = resultsFolder.ensureFolder(scenarioName); - await scenarioOutFolder.ensureExists(); - - const scenarioFolder = scenariosFolder.ensureFolder(scenarioName); - - const isEqual = await StorageUtilities.folderContentsEqual(scenarioFolder, scenarioOutFolder, excludeList, true); - - assert( - isEqual.result, - "Folder '" + scenarioFolder.fullPath + "' does not match for scenario '" + scenarioName + "', " + isEqual.reason - ); -} - -// eslint-disable-next-line @typescript-eslint/no-unused-vars -async function ensureJsonMatchesScenario(obj: object, scenarioName: string) { - if (!scenariosFolder || !resultsFolder) { - assert.fail("Not properly initialized"); - } - - const dataObjectStr = JSON.stringify(obj, null, 2); - - const scenarioOutFolder = resultsFolder.ensureFolder(scenarioName); - await scenarioOutFolder.ensureExists(); - - const outFile = scenarioOutFolder.ensureFile("report.json"); - outFile.setContent(dataObjectStr); - await outFile.saveContent(); - - const scenarioFile = scenariosFolder.ensureFolder(scenarioName).ensureFile("report.json"); - - const exists = await scenarioFile.exists(); - - assert(exists, "report.json file for scenario '" + scenarioName + "' does not exist."); - - const isEqual = await StorageUtilities.fileContentsEqual(scenarioFile, outFile, true); - - assert( - isEqual, - "report.json file '" + scenarioFile.fullPath + "' does not match for scenario '" + scenarioName + "'" - ); -} diff --git a/app/src/tools/BlockStamp.ts b/app/src/tools/BlockStamp.ts deleted file mode 100644 index 3a5cfa54..00000000 --- a/app/src/tools/BlockStamp.ts +++ /dev/null @@ -1,87 +0,0 @@ -import BlockLocation from "../minecraft/BlockLocation"; -import BlockType from "../minecraft/BlockType"; -import IDimension from "../minecraft/IDimension"; - -export class BlockStamp { - static fillBlock( - dimension: IDimension, - blockType: BlockType, - xFrom: number, - yFrom: number, - zFrom: number, - xTo: number, - yTo: number, - zTo: number - ) { - for (let i = xFrom; i <= xTo; i++) { - for (let j = yFrom; j <= yTo; j++) { - for (let k = zFrom; k <= zTo; k++) { - const block = dimension.getBlock(new BlockLocation(i, j, k)); - block.setType(blockType); - } - } - } - } - - static fourWalls( - dimension: IDimension, - blockType: BlockType, - xFrom: number, - yFrom: number, - zFrom: number, - xTo: number, - yTo: number, - zTo: number - ) { - for (let i = xFrom; i <= xTo; i++) { - for (let k = yFrom; k <= yTo; k++) { - let block = dimension.getBlock(new BlockLocation(i, k, zFrom)); - block.setType(blockType); - - block = dimension.getBlock(new BlockLocation(i, k, zTo)); - block.setType(blockType); - } - } - - for (let j = zFrom + 1; j < zTo; j++) { - for (let k = yFrom; k <= yTo; k++) { - let block = dimension.getBlock(new BlockLocation(xFrom, k, j)); - block.setType(blockType); - - block = dimension.getBlock(new BlockLocation(xTo, k, j)); - block.setType(blockType); - } - } - } - - static fourNotchedWalls( - dimension: IDimension, - blockType: BlockType, - xFrom: number, - yFrom: number, - zFrom: number, - xTo: number, - yTo: number, - zTo: number - ) { - for (let i = xFrom + 1; i < xTo; i++) { - for (let k = yFrom; k <= yTo; k++) { - let block = dimension.getBlock(new BlockLocation(i, k, zFrom)); - block.setType(blockType); - - block = dimension.getBlock(new BlockLocation(i, k, zTo)); - block.setType(blockType); - } - } - - for (let j = zFrom + 1; j < zTo; j++) { - for (let k = yFrom; k <= yTo; k++) { - let block = dimension.getBlock(new BlockLocation(xFrom, k, j)); - block.setType(blockType); - - block = dimension.getBlock(new BlockLocation(xTo, k, j)); - block.setType(blockType); - } - } - } -} diff --git a/app/src/vscodeweb/MessageProxy.ts b/app/src/vscodeweb/MessageProxy.ts deleted file mode 100644 index f97d0307..00000000 --- a/app/src/vscodeweb/MessageProxy.ts +++ /dev/null @@ -1,132 +0,0 @@ -import Utilities from "./../core/Utilities"; -import Log from "./../core/Log"; -import { EventDispatcher } from "ste-events"; -import CartoApp from "../app/CartoApp"; - -export enum MessageProxyCommands { - fsExists = "fsExists", - fsFolderExists = "fsFolderExists", - fsMkdir = "fsMkdir", - fsReadUtf8File = "fsReadUtf8File", - fsReadFile = "fsReadFile", - fsWriteUtf8File = "fsWriteUtf8File", - fsWriteFile = "fsWriteFile", - fsReaddir = "fsReaddir", - fsStat = "fsStat", - fsDeleteItem = "fsDeleteItem", - getDirname = "getDirname", - notifyFileAdded = "notifyFileAdded", - notifyFileContentsUpdated = "notifyFileContentsUpdated", - notifyFileRemoved = "notifyFileRemoved", -} - -export default class MessageProxy { - static _pendingPromiseResolvers: ((value: any | PromiseLike) => void)[] = []; - static _pendingPromiseRejecters: ((reason?: any) => void)[] = []; - - private static _onMessage = new EventDispatcher(); - - public static get onMessage() { - return MessageProxy._onMessage.asEvent(); - } - - static init() { - CartoApp.onMessage.subscribe(MessageProxy._handleNewMessage); - } - - static send(commandName: MessageProxyCommands | string, channelId: string, data: any) { - if (!CartoApp.postMessage) { - throw new Error("Post message is not specified"); - } - - if (commandName === MessageProxyCommands.fsWriteFile) { - let content = data.content; - - if (content instanceof Uint8Array) { - content = Utilities.uint8ArrayToBase64(content); - } else if (data instanceof ArrayBuffer) { - content = Utilities.arrayBufferToBase64(content); - } else if ( - data instanceof Uint16Array || - data instanceof Uint32Array || - data instanceof Uint8ClampedArray || - data instanceof BigUint64Array - ) { - Log.fail("Unsupported binary type encountered." + data); - } - - data.content = content; - } - - let result = undefined; - - try { - CartoApp.postMessage({ command: commandName, id: channelId, data: data }); - } catch (e) { - let dataStr = data; - - if (typeof data === "object") { - dataStr = JSON.stringify(data); - } - - throw new Error("Error running command " + commandName + ", data: " + dataStr + ", error: " + e); - } - - if (commandName === MessageProxyCommands.fsReadFile) { - /* if (result === undefined || result.length === 0) { - return undefined; - }*/ - - return Utilities.base64ToArrayBuffer(""); //result); - } - - return result; - } - - static sendAsync(commandName: MessageProxyCommands | string, channelId: string, data: any): Promise { - if (CartoApp.postMessage === undefined) { - throw new Error("Not an post message API"); - } - - const promise = new Promise(MessageProxy._stringPromiseHandler); - const position = MessageProxy._pendingPromiseResolvers.length - 1; - - const commandStr = "async" + (commandName as string) + "|" + position; - - // Log.verbose("Sending message proxy async command '" + commandStr + "'"); - - CartoApp.postMessage({ command: commandStr, id: channelId, data: data }); - - return promise; - } - - private static _stringPromiseHandler( - resolve: (value: string | PromiseLike) => void, - reject: (reason?: any) => void - ) { - const position = MessageProxy._pendingPromiseResolvers.length; - - MessageProxy._pendingPromiseResolvers[position] = resolve; - MessageProxy._pendingPromiseRejecters[position] = reject; - } - - private static _handleNewMessage(source: any, message: any) { - if (message.command && message.command.length > 0) { - if (message.command.startsWith("async")) { - const argSplit = message.command.split("|"); - - if (argSplit.length >= 2) { - const index = parseInt(argSplit[1]); - - if (index >= 0) { - const promiseResolver = MessageProxy._pendingPromiseResolvers[index]; - - promiseResolver(message.data); - } - } - } else { - MessageProxy._onMessage.dispatch("messageproxy", message); - } - } - } -} diff --git a/app/src/vscodeweb/MessageProxyFile.ts b/app/src/vscodeweb/MessageProxyFile.ts deleted file mode 100644 index eb7a7f6c..00000000 --- a/app/src/vscodeweb/MessageProxyFile.ts +++ /dev/null @@ -1,209 +0,0 @@ -import MessageProxyFolder from "./MessageProxyFolder"; -import MessageProxyStorage from "./MessageProxyStorage"; -import IFile from "../storage/IFile"; -import FileBase from "../storage/FileBase"; -import MessageProxy, { MessageProxyCommands } from "./MessageProxy"; -import StorageUtilities, { EncodingType } from "../storage/StorageUtilities"; -import Log from "../core/Log"; -import Utilities from "../core/Utilities"; - -export default class MessageProxyFile extends FileBase implements IFile { - _name: string; - _parentFolder: MessageProxyFolder; - - get name() { - return this._name; - } - - get fullPath() { - let path = this._parentFolder.fullPath; - - if (!path.endsWith(MessageProxyStorage.folderDelimiter)) { - path += MessageProxyStorage.folderDelimiter; - } - - return path + this.name; - } - - get parentFolder(): MessageProxyFolder { - return this._parentFolder; - } - - get isContentLoaded(): boolean { - return this.lastLoadedOrSaved != null || this.modified != null; - } - - constructor(parentFolder: MessageProxyFolder, folderName: string) { - super(); - - this._parentFolder = parentFolder; - this._name = folderName; - } - - async exists(): Promise { - return await MessageProxy.sendAsync( - MessageProxyCommands.fsExists, - this.parentFolder.storage.channelId, - this.fullPath - ); - } - - async reload() { - this.lastLoadedOrSaved = null; - await this.loadContent(false); - } - - async loadContent(force: boolean): Promise { - if (force || this.lastLoadedOrSaved == null) { - if (!this.parentFolder.storage.isEnabled) { - Log.debugAlert( - "Unexpected usage of a disabled storage (loading file content) on storage '" + - this.parentFolder.storage.channelId + - "'" - ); - throw new Error(); - } - - const encoding = StorageUtilities.getEncodingByFileName(this._name); - - if (encoding === EncodingType.ByteBuffer) { - // Log.debug(`MP loading '${this.fullPath}' as binary on storage '${this.parentFolder.storage.channelId}'`); - - const byteResult = await MessageProxy.sendAsync( - MessageProxyCommands.fsReadFile, - this.parentFolder.storage.channelId, - this.fullPath - ); - - if (byteResult instanceof Uint8Array) { - this._content = byteResult; - } else if (typeof byteResult === "string") { - if (byteResult === "null" || byteResult === "|null|") { - this._content = null; - } else { - const arrayBuf = Utilities.base64ToArrayBuffer(byteResult); - - if (arrayBuf) { - this._content = new Uint8Array(arrayBuf); - } else { - this._content = null; - } - } - } else if (byteResult === undefined) { - this._content = byteResult; - } else { - Log.debugAlert("Unknown file received: " + this.fullPath + "|" + byteResult + "|" + typeof byteResult); - this._content = byteResult; - } - } else { - /*Log.debug( - "MP loading '" + this.fullPath + "' as text on storage '" + this.parentFolder.storage.channelId + "'" - );*/ - - let result: string | null = await MessageProxy.sendAsync( - MessageProxyCommands.fsReadUtf8File, - this.parentFolder.storage.channelId, - this.fullPath - ); - - if (result === "null" || result === "|null|") { - result = null; - } - - this._content = result; - } - - // this._content += ""; - this.lastLoadedOrSaved = new Date(); - } - - return this.lastLoadedOrSaved; - } - - setContent(newContent: string | Uint8Array | null) { - const areEqual = StorageUtilities.contentsAreEqual(this._content, newContent); - - if (!areEqual) { - if (!this.lastLoadedOrSaved) { - this.lastLoadedOrSaved = new Date(); - this.lastLoadedOrSaved = new Date(this.lastLoadedOrSaved.getTime() - 1); - - // Log.debugAlert("Setting a file without loading it first."); - } - - this._content = newContent; - - this.contentWasModified(); - } - } - - async saveContent(): Promise { - if (this.content != null) { - await this.parentFolder.ensureExists(); - - const encoding = StorageUtilities.getEncodingByFileName(this._name); - - if (encoding === EncodingType.ByteBuffer) { - // Log.verbose(`MPX saving '${this.fullPath}' as binary. size: ${this.content.length}`); - - MessageProxy.send(MessageProxyCommands.fsWriteFile, this.parentFolder.storage.channelId, { - path: this.fullPath, - content: this.content, - }); - } else { - // Log.verbose(`MPX saving '${this.fullPath}' as text. size: ${this.content.length}`); - - MessageProxy.send(MessageProxyCommands.fsWriteUtf8File, this.parentFolder.storage.channelId, { - path: this.fullPath, - content: this.content, - }); - } - } else { - Log.verbose(`MPX note '${this.fullPath}' is null and can't be saved.`); - } - - this.lastLoadedOrSaved = new Date(); - - return this.lastLoadedOrSaved; - } - - async deleteFile(): Promise { - this._parentFolder._removeFile(this); - - MessageProxy.send(MessageProxyCommands.fsDeleteItem, this.parentFolder.storage.channelId, this.fullPath); - - return true; - } - - async moveTo(newStorageRelativePath: string): Promise { - const newFolderPath = StorageUtilities.getPath(newStorageRelativePath); - const newFileName = StorageUtilities.getLeafName(newStorageRelativePath); - - if (newFileName.length < 2) { - throw new Error("New path is not correct."); - } - - const newParentFolder = await this._parentFolder.storage.ensureFolderFromStorageRelativePath(newFolderPath); - - if (newParentFolder.files[newFileName] !== undefined) { - throw new Error("File exists at specified path."); - } - - await this.loadContent(false); - - const originalPath = this.fullPath; - - this._name = newFileName; - this._parentFolder = newParentFolder as MessageProxyFolder; - - this.modified = new Date(); - - (newParentFolder as MessageProxyFolder)._addExistingFile(this); - - this._recycleItem(originalPath); - - return true; - } - - async _recycleItem(path: string) {} -} diff --git a/app/src/vscodeweb/MessageProxyFolder.ts b/app/src/vscodeweb/MessageProxyFolder.ts deleted file mode 100644 index 26e051e9..00000000 --- a/app/src/vscodeweb/MessageProxyFolder.ts +++ /dev/null @@ -1,229 +0,0 @@ -import IFolder from "./../storage/IFolder"; -import IFile from "./../storage/IFile"; -import MessageProxyFile from "./MessageProxyFile"; -import MessageProxyStorage from "./MessageProxyStorage"; -import StorageUtilities from "./../storage/StorageUtilities"; -import FolderBase from "./../storage/FolderBase"; -import MessageProxy, { MessageProxyCommands } from "./MessageProxy"; -import Log from "./../core/Log"; - -export default class MessageProxyFolder extends FolderBase implements IFolder { - private _name: string; - private _path: string; - - folders: { [id: string]: MessageProxyFolder | undefined }; - files: { [id: string]: MessageProxyFile | undefined }; - private _storage: MessageProxyStorage; - private _parentFolder: MessageProxyFolder | null; - - get storage(): MessageProxyStorage { - return this._storage; - } - - get parentFolder(): MessageProxyFolder | null { - return this._parentFolder; - } - - get name() { - return this._name; - } - - get fullPath() { - let path = this._path; - - if (!path.endsWith(MessageProxyStorage.folderDelimiter)) { - path += MessageProxyStorage.folderDelimiter; - } - - path += this.name; - - if (!path.endsWith(MessageProxyStorage.folderDelimiter)) { - path += MessageProxyStorage.folderDelimiter; - } - - return path; - } - - constructor( - storage: MessageProxyStorage, - parentFolder: MessageProxyFolder | null, - parentPath: string, - folderName: string - ) { - super(); - - this._storage = storage; - this._parentFolder = parentFolder; - - this._path = parentPath; - this._name = folderName; - - this.folders = {}; - this.files = {}; - } - - ensureFile(name: string): MessageProxyFile { - const nameCanon = StorageUtilities.canonicalizeName(name); - - let candFile = this.files[nameCanon]; - - if (candFile == null) { - candFile = new MessageProxyFile(this, name); - - this.files[nameCanon] = candFile; - } - - return candFile; - } - - _removeFile(file: IFile) { - const nameCanon = StorageUtilities.canonicalizeName(file.name); - - const candFile = this.files[nameCanon]; - - Log.assert(candFile === file, "Files don't match."); - - this.files[nameCanon] = undefined; - - this.storage.notifyFileRemoved(this.storageRelativePath + file.name); - } - - _addExistingFile(file: MessageProxyFile) { - const nameCanon = StorageUtilities.canonicalizeName(file.name); - - this.files[nameCanon] = file; - } - - ensureFolder(name: string): MessageProxyFolder { - const nameCanon = StorageUtilities.canonicalizeName(name); - - let candFolder = this.folders[nameCanon]; - - if (!candFolder) { - candFolder = new MessageProxyFolder(this._storage, this, this.fullPath, name); - - this.folders[nameCanon] = candFolder; - } - - return candFolder; - } - - async exists(): Promise { - return await MessageProxy.sendAsync(MessageProxyCommands.fsFolderExists, this.storage.channelId, this.fullPath); - } - - async ensureExists(): Promise { - const exists = await MessageProxy.sendAsync( - MessageProxyCommands.fsFolderExists, - this.storage.channelId, - this.fullPath - ); - - if (!exists) { - // Log.message("Creating folder '" + this.fullPath + "'"); - - try { - await MessageProxy.sendAsync(MessageProxyCommands.fsMkdir, this.storage.channelId, this.fullPath); - } catch (e) { - return false; - } - } - - return true; - } - - _addExistingFolder(folder: MessageProxyFolder) { - const nameCanon = StorageUtilities.canonicalizeName(folder.name); - - this.folders[nameCanon] = folder; - } - - async moveTo(newStorageRelativePath: string): Promise { - // let oldFullPath = this.fullPath; - - const newFolderPath = StorageUtilities.getPath(newStorageRelativePath); - const newFolderName = StorageUtilities.getLeafName(newStorageRelativePath); - - if (newFolderName.length < 2) { - throw new Error("New path is not correct."); - } - - if (this._parentFolder !== null) { - const newParentFolder = await this._parentFolder.storage.ensureFolderFromStorageRelativePath(newFolderPath); - - if (newParentFolder.folders[newFolderName] !== undefined) { - throw new Error("Folder exists at specified path."); - } - - this._parentFolder = newParentFolder as MessageProxyFolder; - - this._name = newFolderName; - - (newParentFolder as MessageProxyFolder)._addExistingFolder(this); - } - - this._name = newFolderName; - - // let newFullPath = this.fullPath; - - throw new Error("Not implemented exception"); - // fs.renameSync(oldFullPath, newFullPath); - - // return true; - } - - async createFile(name: string): Promise { - return this.ensureFile(name); - } - - async load(force: boolean): Promise { - if (this.lastProcessed != null && !force) { - return this.lastProcessed; - } - - if (!this.storage.isEnabled) { - Log.debugAlert( - "Unexpected usage of a disabled storage (loading folder '" + - this.fullPath + - "') on storage '" + - this.storage.channelId + - "'" - ); - throw new Error(); - } - - const results = (await MessageProxy.sendAsync( - MessageProxyCommands.fsReaddir, - this.storage.channelId, - this.fullPath - )) as string[]; - - for (const fileName of results) { - if (StorageUtilities.isUsableFile(fileName)) { - let filePath = this.fullPath; - - if (!filePath.endsWith(MessageProxyStorage.folderDelimiter)) { - filePath += MessageProxyStorage.folderDelimiter; - } - - filePath += fileName; - - const stat = await MessageProxy.sendAsync(MessageProxyCommands.fsStat, this.storage.channelId, filePath); - - if (stat.isDirectory) { - this.ensureFolder(fileName); - } else if (stat.isFile && StorageUtilities.isUsableFile(filePath)) { - const file = this.ensureFile(fileName); - - if (stat.mtime) { - file.modifiedAtLoad = new Date(stat.mtime); - } - } - } - } - - this.updateLastProcessed(); - - return this.lastProcessed as Date; - } -} diff --git a/app/src/vscodeweb/MessageProxyStorage.ts b/app/src/vscodeweb/MessageProxyStorage.ts deleted file mode 100644 index e76aab27..00000000 --- a/app/src/vscodeweb/MessageProxyStorage.ts +++ /dev/null @@ -1,105 +0,0 @@ -import MessageProxyFolder from "./MessageProxyFolder"; -import StorageBase from "./../storage/StorageBase"; -import IStorage from "./../storage/IStorage"; -import Log from "../core/Log"; -import CartoApp from "../app/CartoApp"; -import { MessageProxyCommands } from "./MessageProxy"; -import IFile from "../storage/IFile"; -import MessageProxyFile from "./MessageProxyFile"; - -export default class MessageProxyStorage extends StorageBase implements IStorage { - path: string; - name?: string; - channelId: string; - isEnabled: boolean = true; - rootFolder: MessageProxyFolder; - - static folderDelimiter = "\\"; - - static determineDelimiter(path: string) { - if (path.indexOf("\\") >= 0) { - MessageProxyStorage.folderDelimiter = "\\"; - } else { - MessageProxyStorage.folderDelimiter = "/"; - } - } - - constructor(channelId: string, path: string, name?: string) { - super(); - - Log.assert(channelId !== "", "Unexpected empty channel"); - this.channelId = channelId; - - this.path = path; - this.name = name; - - if (!name) { - name = ""; - } - - this.rootFolder = new MessageProxyFolder(this, null, path, name); - - CartoApp.onMessage.subscribe(this._handleNewMessage); - } - - private _handleNewMessage(source: any, message: any) { - if (message.command && message.command.length > 0 && message.id === this.channelId) { - if (message === MessageProxyCommands.notifyFileAdded) { - const srPath = message; - - this.rootFolder.ensureFileFromRelativePath(srPath).then(async (val) => { - if (val) { - await (val as MessageProxyFile).reload(); - - this.notifyFileAdded(val as IFile); - } else { - Log.unexpectedUndefined("HNM"); - } - }); - } else if (message === MessageProxyCommands.notifyFileRemoved) { - const srPath = message; - - this.rootFolder.ensureFileFromRelativePath(srPath).then(async (val) => { - if (val) { - await (val as MessageProxyFile).deleteFile(); - this.notifyFileRemoved(srPath); - } - }); - } else if (message === MessageProxyCommands.notifyFileContentsUpdated) { - const srPath = message; - - this.rootFolder.getFileFromRelativePath(srPath).then(async (val) => { - if (val) { - await (val as MessageProxyFile).reload(); - - this.notifyFileContentsUpdated(val as IFile); - } else { - Log.unexpectedUndefined("HNMA"); - } - }); - } - } - } - - joinPath(pathA: string, pathB: string) { - let fullPath = pathA; - - if (!fullPath.endsWith(MessageProxyStorage.folderDelimiter)) { - fullPath += MessageProxyStorage.folderDelimiter; - } - - fullPath += pathB; - - return fullPath; - } - - static getParentFolderPath(path: string) { - const lastDelim = path.lastIndexOf(this.folderDelimiter); - - if (lastDelim < 0) { - return path; - } - - return path.substring(0, lastDelim); - } -} diff --git a/app/src/vscodeweb/VsWebLocalUtilities.ts b/app/src/vscodeweb/VsWebLocalUtilities.ts deleted file mode 100644 index a321f261..00000000 --- a/app/src/vscodeweb/VsWebLocalUtilities.ts +++ /dev/null @@ -1,97 +0,0 @@ -import ILocalUtilities from "../local/ILocalUtilities"; -import MessageProxyStorage from "./MessageProxyStorage"; -import Log from "./../core/Log"; -import IStorage from "../storage/IStorage"; - -export default class VsWebLocalUtilities implements ILocalUtilities { - readonly userDataPath: string = ""; - - readonly localAppDataPath: string = ""; - readonly localServerLogPath: string = ""; - - readonly minecraftPath: string = ""; - readonly minecraftPreviewPath: string = ""; - - private extensionStorage: MessageProxyStorage; - - constructor() { - this.extensionStorage = new MessageProxyStorage("extension", ""); - - this.readJsonFile = this.readJsonFile.bind(this); - } - - validateFolderPath(path: string): void {} - - countChar(source: string, find: string) { - let count = 0; - - let index = source.indexOf(find); - - while (index >= 0) { - count++; - - index = source.indexOf(find, index + find.length); - } - - return count; - } - - ensureStartsWithSlash(pathSegment: string) { - if (!pathSegment.startsWith("/")) { - pathSegment = "/" + pathSegment; - } - - return pathSegment; - } - - ensureEndsWithSlash(pathSegment: string) { - if (!pathSegment.endsWith("/")) { - pathSegment += "/"; - } - - return pathSegment; - } - - ensureStartsWithBackSlash(pathSegment: string) { - if (!pathSegment.startsWith("\\")) { - pathSegment = "\\" + pathSegment; - } - - return pathSegment; - } - - ensureEndsWithBackSlash(pathSegment: string) { - if (!pathSegment.endsWith("\\")) { - pathSegment += "\\"; - } - - return pathSegment; - } - - async createStorage(path: string): Promise { - return new MessageProxyStorage(path, ""); - } - - async readJsonFile(path: string): Promise { - path = this.ensureStartsWithSlash(path); - - try { - const catFile = await this.extensionStorage.rootFolder.ensureFileFromRelativePath(path); - - await catFile.loadContent(); - - if (!catFile.content) { - Log.fail(path + " has no content"); - return null; - } - - if (typeof catFile.content === "string") { - return JSON.parse(catFile.content); - } - } catch (e) { - Log.debugAlert("Content load fail: " + e); - } - - return null; - } -} diff --git a/app/src/worldtest/IWorldTestArea.ts b/app/src/worldtest/IWorldTestArea.ts deleted file mode 100644 index 90d726dc..00000000 --- a/app/src/worldtest/IWorldTestArea.ts +++ /dev/null @@ -1,12 +0,0 @@ -import IAutoScriptData from "./../autoscript/IAutoScriptData.js"; - -export enum WorldTestItemType { - setBlock = 1, - spawnEntity = 2, - runCommand = 5, -} - -export default interface IWorldTestArea { - location: number[]; - scripts: IAutoScriptData[]; -} diff --git a/app/src/worldtest/IWorldTestDefinition.ts b/app/src/worldtest/IWorldTestDefinition.ts deleted file mode 100644 index f9c96955..00000000 --- a/app/src/worldtest/IWorldTestDefinition.ts +++ /dev/null @@ -1,7 +0,0 @@ -import IWorldTestArea from "./IWorldTestArea"; - -export default interface IWorldTestDefinition { - name: string; - areas: IWorldTestArea[]; - worldId?: string; -} diff --git a/app/src/worldtest/WorldTest.ts b/app/src/worldtest/WorldTest.ts deleted file mode 100644 index b9fb6b1a..00000000 --- a/app/src/worldtest/WorldTest.ts +++ /dev/null @@ -1,91 +0,0 @@ -import IWorldTestDefinition from "./IWorldTestDefinition"; -import WorldTestArea from "./WorldTestArea"; - -export default class WorldTest { - public data: IWorldTestDefinition; - public areas: WorldTestArea[]; - - #isLoaded: boolean; - - constructor(data: IWorldTestDefinition) { - this.#isLoaded = false; - this.areas = []; - this.data = data; - } - - public ensureLoaded() { - if (this.data.areas) { - for (const area of this.data.areas) { - const areaWrap = new WorldTestArea(this, area); - this.areas.push(areaWrap); - } - } - - this.#isLoaded = true; - } - - public get isLoaded() { - return this.#isLoaded; - } - - public get worldId() { - return this.data.worldId; - } - - public set worldId(newWorldId: string | undefined) { - this.data.worldId = newWorldId; - } - - public get name() { - if (this.data === undefined) { - return ""; - } - - return this.data.name; - } - - public set name(newName: string) { - if (this.data === undefined) { - return; - } - - this.data.name = newName; - } - - generateJavaScript() { - return ""; - } - - generateGameTestJavaScript(name: string) { - const scripts: string[] = []; - - scripts.push('import { register, registerAsync, Test, SimulatedPlayer } from "@minecraft/server-gametest";'); - scripts.push('import { BlockLocation, Location, world } from "@minecraft/server";'); - - for (let i = 0; i < this.areas.length; i++) { - const area = this.areas[i]; - - scripts.push(area.generateGameTestJavaScript(area.title)); - } - - return scripts.join("\r\n"); - } - - generateCommandLine() { - return ""; - } - - createArea(type: string) { - const area = new WorldTestArea(this, { location: [], scripts: [] }); - - if (area) { - this.areas.push(area); - - if (!this.data.areas) { - this.data.areas = []; - } - - this.data.areas.push(area.data); - } - } -} diff --git a/app/src/worldtest/WorldTestArea.ts b/app/src/worldtest/WorldTestArea.ts deleted file mode 100644 index 08d92d86..00000000 --- a/app/src/worldtest/WorldTestArea.ts +++ /dev/null @@ -1,115 +0,0 @@ -import IWorldTestArea from "./IWorldTestArea"; -import WorldTest from "./WorldTest.js"; -import BlockLocation from "./../minecraft/BlockLocation"; -import AutoScript from "../autoscript/AutoScript"; -import { EventDispatcher } from "ste-events"; - -export default class WorldTestArea { - private _test: WorldTest; - data: IWorldTestArea; - public scripts: AutoScript[]; - private _isLoaded: boolean; - private _location: BlockLocation | undefined; - private _onPropertyChanged = new EventDispatcher(); - - getProperty(id: string): any { - switch (id) { - case "location": - return this.location.toArray(); - } - } - - setProperty(id: string, value: any): void { - switch (id) { - case "location": - this.location = BlockLocation.from(value); - } - } - - public get onPropertyChanged() { - return this._onPropertyChanged.asEvent(); - } - - get location(): BlockLocation { - if (!this._location) { - let x = 0; - let y = 0; - let z = 0; - - if (this.data.location && this.data.location.length && this.data.location.length === 3) { - x = this.data.location[0]; - y = this.data.location[1]; - z = this.data.location[2]; - } - this._location = new BlockLocation(x, y, z); - } - - return this._location; - } - - set location(location: BlockLocation) { - if ( - (!this._location && location) || - (this._location && - (this._location.x !== location.x || this._location.y !== location.y || this._location.z !== location.z)) - ) { - this._location = location; - - for (let i = 0; i < this.scripts.length; i++) { - this.scripts[i].locationRoot = this._location.toLocation(); - } - - this._onPropertyChanged.dispatch(this, "location"); - } - } - - get title(): string { - const loc = this.location; - - return "test" + loc.title; - } - - constructor(test: WorldTest, data: IWorldTestArea) { - this._isLoaded = false; - this.scripts = []; - this.data = data; - this._test = test; - } - - generateGameTestJavaScript(groupName: string) { - const scripts: string[] = []; - - for (let i = 0; i < this.scripts.length; i++) { - const script = this.scripts[i]; - - let scriptName = groupName; - if (this.scripts.length > 1) { - scriptName += (i + 1).toString(); - } - scripts.push(script.generateGameTestJavaScript(scriptName, (i + 1).toString(), this._test.name)); - } - - return scripts.join("\r\n"); - } - - createScript(type: string) { - const as = new AutoScript({ - name: "Area Script", - actions: [], - }); - - if (as) { - if (this._location) { - as.locationRoot = this._location.toLocation(); - } - - this.scripts.push(as); - - if (!this.data.scripts) { - this.data.scripts = []; - } - - this.data.scripts.push(as.scriptData); - } - } -} diff --git a/app/test/scenarios/simple/report.json b/app/test/scenarios/simple/report.json index 86a10fc0..3650bceb 100644 --- a/app/test/scenarios/simple/report.json +++ b/app/test/scenarios/simple/report.json @@ -17,10 +17,10 @@ "chunkCount": 0, "features": { "Behavior pack manifest content-size count": 1, - "Behavior pack manifest content-size total": 18, - "Behavior pack manifest content-size max": 18, - "Behavior pack manifest content-size min": 18, - "Behavior pack manifest content-size average": 18, + "Behavior pack manifest content-size total": 28, + "Behavior pack manifest content-size max": 28, + "Behavior pack manifest content-size min": 28, + "Behavior pack manifest content-size average": 28, "Image content-size count": 1, "Image content-size total": 8092, "Image content-size max": 8092, @@ -100,10 +100,10 @@ "itemStoragePath": "/behavior_packs/StarterTestsTutorial/manifest.json", "features": { "content-size count": 1, - "content-size total": 18, - "content-size max": 18, - "content-size min": 18, - "content-size average": 18 + "content-size total": 28, + "content-size max": 28, + "content-size min": 28, + "content-size average": 28 } }, { @@ -186,7 +186,20 @@ 10 ] }, - "modules": [], + "modules": [ + { + "description": "Starter Hello World Tests script", + "language": "javascript", + "type": "script", + "uuid": "5784dba1-588a-4f44-9f0d-c55744708353", + "version": [ + 0, + 0, + 1 + ], + "entry": "scripts/index.js" + } + ], "dependencies": [] } }, @@ -261,22 +274,28 @@ "message": "No world template was found; base game version check passes." }, { - "itemType": 0, + "itemType": 2, "generatorId": "BPENTITYTYPE", - "generatorIndex": 260, - "message": "No entity type behavior format version was found; base game version check passes." + "generatorIndex": 2, + "message": "Entity Type Runtime Identifier" }, { "itemType": 2, - "generatorId": "ESLINT", - "generatorIndex": 1, - "message": "JS file: /behavior_packs/StarterTestsTutorial/scripts/index.js" + "generatorId": "BPENTITYTYPE", + "generatorIndex": 3, + "message": "Entity Type Identifier" }, { "itemType": 2, - "generatorId": "ESLINT", - "generatorIndex": 1, - "message": "JS file: /behavior_packs/StarterTestsTutorial/scripts/starttests.js" + "generatorId": "BPENTITYTYPE", + "generatorIndex": 4, + "message": "Entity Type Metadata" + }, + { + "itemType": 0, + "generatorId": "BPENTITYTYPE", + "generatorIndex": 260, + "message": "No entity type behavior format version was found; base game version check passes." }, { "itemType": 2, @@ -311,27 +330,6 @@ "message": "Commands", "itemStoragePath": "/behavior_packs/StarterTestsTutorial/manifest.json" }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 1, - "message": "Blocks", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/pack_icon.png" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 2, - "message": "Block Data", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/pack_icon.png" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 3, - "message": "Commands", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/pack_icon.png" - }, { "itemType": 2, "generatorId": "WORLDDATA", @@ -353,48 +351,6 @@ "message": "Commands", "itemStoragePath": "/behavior_packs/StarterTestsTutorial/scripts/index.js" }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 1, - "message": "Blocks", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/scripts/starttests.js" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 2, - "message": "Block Data", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/scripts/starttests.js" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 3, - "message": "Commands", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/scripts/starttests.js" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 1, - "message": "Blocks", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 2, - "message": "Block Data", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure" - }, - { - "itemType": 2, - "generatorId": "WORLDDATA", - "generatorIndex": 3, - "message": "Commands", - "itemStoragePath": "/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure" - }, { "itemType": 0, "generatorId": "UNKFILE", @@ -427,5 +383,6 @@ } ], "generatorName": "Minecraft Creator Tools", - "generatorVersion": "0.1.58" + "suite": 0, + "generatorVersion": "0.1.63" } \ No newline at end of file diff --git a/app/test/scenarios/worldCommand/behavior_packs/worldcommand/scripts/generated/LocalWorld.js b/app/test/scenarios/worldCommand/behavior_packs/worldcommand/scripts/generated/LocalWorld.js deleted file mode 100644 index 745fb885..00000000 --- a/app/test/scenarios/worldCommand/behavior_packs/worldcommand/scripts/generated/LocalWorld.js +++ /dev/null @@ -1,4 +0,0 @@ -export default const worldCommand = { - anchors: { - } -} \ No newline at end of file diff --git a/app/test/scenarios/worldCommand/level.dat b/app/test/scenarios/worldCommand/level.dat deleted file mode 100644 index 2de48cc0c2ef67d970e959f2ebc199ceaf19e84e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 zcmd;LU|`SzVlE)!WJpZP%*iatOf6>M;$}##C`c{J%uUTJDQ4tgNKed7ElDjdVPs$c E00x8%Hvj+t diff --git a/app/test/scenarios/worldCommand/level.dat_old b/app/test/scenarios/worldCommand/level.dat_old deleted file mode 100644 index 2de48cc0c2ef67d970e959f2ebc199ceaf19e84e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 52 zcmd;LU|`SzVlE)!WJpZP%*iatOf6>M;$}##C`c{J%uUTJDQ4tgNKed7ElDjdVPs$c E00x8%Hvj+t diff --git a/app/test/scenarios/worldCommand/levelname.txt b/app/test/scenarios/worldCommand/levelname.txt deleted file mode 100644 index 6e1f5a7b..00000000 --- a/app/test/scenarios/worldCommand/levelname.txt +++ /dev/null @@ -1 +0,0 @@ -worldCommand \ No newline at end of file diff --git a/app/tools/gulp-downloadResources/DownloadResources.js b/app/tools/gulp-downloadResources/DownloadResources.js index 6d5ecd8d..9428a38f 100644 --- a/app/tools/gulp-downloadResources/DownloadResources.js +++ b/app/tools/gulp-downloadResources/DownloadResources.js @@ -85,7 +85,15 @@ class DownloadResources { const extension = me.getTypeFromName(filenameCanon); - if (extension === "" && filenameCanon.endsWith("/license")) { + if ( + (extension === "" || extension === "md") && + (filenameCanon.endsWith("/notice") || + filenameCanon.endsWith("/readme") || + filenameCanon.endsWith("/readme.md") || + filenameCanon.endsWith("/license") || + filenameCanon.endsWith("/license.md") || + filenameCanon.endsWith("/notice.md")) + ) { addFile = true; } diff --git a/tests/deployJs/behavior_packs/deployJs/manifest.json b/tests/deployJs/behavior_packs/deployJs/manifest.json new file mode 100644 index 00000000..dfaf9744 --- /dev/null +++ b/tests/deployJs/behavior_packs/deployJs/manifest.json @@ -0,0 +1,43 @@ +{ + "format_version": 2, + "__comment__": "===== AUTOGENERATED FILE ===== CONTENT WITHIN THIS FILE WILL BE WIPED AND UPDATED WHEN USED IN TOOLING", + "header": { + "description": "deployJs description", + "name": "deployJs", + "uuid": "0917e16e-8044-4f14-a26c-03116760ed3d", + "version": [ + 0, + 0, + 1 + ], + "min_engine_version": [ + 1, + 20, + 10 + ] + }, + "modules": [ + { + "description": "deployJs script", + "language": "javascript", + "type": "script", + "uuid": "bae79ded-3acc-4d22-ae8f-9a7a91b34d12", + "version": [ + 0, + 0, + 1 + ], + "entry": "scripts/index.js" + } + ], + "dependencies": [ + { + "module_name": "@minecraft/server", + "version": "1.1.0-beta" + }, + { + "module_name": "@minecraft/server-gametest", + "version": "1.0.0-beta" + } + ] +} \ No newline at end of file diff --git a/app/test/scenarios/deployCommand/development_behavior_packs/simple/scripts/index.js b/tests/deployJs/behavior_packs/deployJs/scripts/index.js similarity index 100% rename from app/test/scenarios/deployCommand/development_behavior_packs/simple/scripts/index.js rename to tests/deployJs/behavior_packs/deployJs/scripts/index.js diff --git a/app/test/scenarios/deployCommand/development_behavior_packs/simple/scripts/starttests.js b/tests/deployJs/behavior_packs/deployJs/scripts/starttests.js similarity index 100% rename from app/test/scenarios/deployCommand/development_behavior_packs/simple/scripts/starttests.js rename to tests/deployJs/behavior_packs/deployJs/scripts/starttests.js diff --git a/app/test/scenarios/deployCommand/development_behavior_packs/simple/manifest.json b/tests/simple/behavior_packs/StarterTestsTutorial/manifest.json similarity index 100% rename from app/test/scenarios/deployCommand/development_behavior_packs/simple/manifest.json rename to tests/simple/behavior_packs/StarterTestsTutorial/manifest.json diff --git a/app/test/scenarios/deployCommand/development_behavior_packs/simple/pack_icon.png b/tests/simple/behavior_packs/StarterTestsTutorial/pack_icon.png similarity index 100% rename from app/test/scenarios/deployCommand/development_behavior_packs/simple/pack_icon.png rename to tests/simple/behavior_packs/StarterTestsTutorial/pack_icon.png diff --git a/tests/simple/behavior_packs/StarterTestsTutorial/scripts/index.js b/tests/simple/behavior_packs/StarterTestsTutorial/scripts/index.js new file mode 100644 index 00000000..fe71c0d9 --- /dev/null +++ b/tests/simple/behavior_packs/StarterTestsTutorial/scripts/index.js @@ -0,0 +1,4 @@ + +// ===== AUTOGENERATED CONTENT ===== CONTENT AT OR BELOW THIS LINE WILL BE WIPED AND UPDATED WHEN USED IN TOOLING + +import "starttests.js"; \ No newline at end of file diff --git a/tests/simple/behavior_packs/StarterTestsTutorial/scripts/starttests.js b/tests/simple/behavior_packs/StarterTestsTutorial/scripts/starttests.js new file mode 100644 index 00000000..409fe113 --- /dev/null +++ b/tests/simple/behavior_packs/StarterTestsTutorial/scripts/starttests.js @@ -0,0 +1,20 @@ +import * as GameTest from "@minecraft/server-gametest"; +import { BlockLocation } from "@minecraft/server"; + +GameTest.register("StarterTests", "simpleMobTest", (test) => { + const attackerId = "fox"; + const victimId = "chicken"; + + test.spawn(attackerId, new BlockLocation(5, 2, 5)); + test.spawn(victimId, new BlockLocation(2, 2, 2)); + + + test.assertEntityPresentInArea(victimId, true); + + // Succeed when the victim dies + test.succeedWhen(() => { + test.assertEntityPresentInArea(victimId, false); + }); +}) + .maxTicks(400) + .structureName("starttests:mediumglass"); /* use the mediumglass.mcstructure file */ diff --git a/tests/simple/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure b/tests/simple/behavior_packs/StarterTestsTutorial/structures/starttests/mediumglass.mcstructure new file mode 100644 index 0000000000000000000000000000000000000000..8e0b5eb4fb36fef93b8e4a9dbf958f659a73971d GIT binary patch literal 9872 zcmeI2(MrQG6o$`iacgxdh+g{~zD!Bm(-G{Fk)#UV`7S<@FQiGg*xg92f*bM&PMgw` zLcWtflYM{shyRX4u;>q^-qAn+1V8`; zKmY_l00ck)1V8`;KmY_l00cnb4+&%oV&$ZhZ2MEjd`=tDvUBWvH8-Mb-KWJWz6pM; zMM_Gnc}Z)jxH6(~_d=Td)H}0;^B+s*v~zMLZ&$OJez}*vYK66918(*PRJtr%woWVl ua#()7vx9B4^|R8dsD%?@YT4~z8Y`Z(Y3o88xss~4m)&{h!87&}Qa=EF{N%3y literal 0 HcmV?d00001