Skip to content

Commit

Permalink
fix(gallery): Update gallery samples and registrations
Browse files Browse the repository at this point in the history
- Refactor loading in app.tsx
  • Loading branch information
mammerla committed Oct 17, 2024
1 parent e8f4c2c commit 1ff1bb2
Show file tree
Hide file tree
Showing 8 changed files with 226 additions and 218 deletions.
44 changes: 42 additions & 2 deletions app/public/data/gallery.json
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,50 @@
"id": "cubeGenerator",
"type": 3
},
{
"title": "Phantoms should fly from cats",
"topics": ["Test.spawn", "Test.assertEntityPresentInArea", "register"],
"sampleSet": "server-gametest-beta",
"localLogo": "blocks/cobblestone.png",
"id": "phantomsShouldFlyFromCats",
"type": 3
},
{
"title": "Tests a roller coaster obstacle course.",
"topics": ["Test.spawn", "Test.assertEntityPresentInArea", "register"],
"sampleSet": "server-gametest-beta",
"localLogo": "blocks/cobblestone.png",
"id": "minibiomes",
"type": 3
},
{
"title": "A simple mob test - the fox should attack the chicken.",
"topics": ["Test.spawn", "Test.assertEntityPresentInArea", "register"],
"sampleSet": "server-gametest-beta",
"localLogo": "blocks/cobblestone.png",
"id": "simpleMobGameTest",
"type": 3
},
{
"title": "Get Player Profile",
"topics": ["variables", "secrets"],
"sampleSet": "server-admin-beta",
"localLogo": "blocks/cobblestone.png",
"id": "getPlayerProfile",
"type": 3
},
{
"title": "Update score via Http Request",
"topics": ["HttpRequestMethod", "HttpHeader", "HttpResponse"],
"sampleSet": "server-net-beta",
"localLogo": "blocks/cobblestone.png",
"id": "updateScore",
"type": 3
},
{
"title": "Translated Message Form",
"topics": ["MessageFormData", "MessageFormResponse", "World.getPlayers"],
"sampleSet": "server",
"sampleSet": "server-ui",
"localLogo": "ui/dialog_background_opaque_overlap_bottom.png",
"id": "showTranslatedMessageForm",
"type": 3
Expand Down Expand Up @@ -862,7 +902,7 @@
"topics": ["MessageFormData", "MessageFormResponse", "World.getPlayers"],
"sampleSet": "server-ui",
"localLogo": "ui/timer.png",
"id": "showBasicMesageForm",
"id": "showBasicMessageForm",
"type": 3
},
{
Expand Down
39 changes: 21 additions & 18 deletions app/public/data/snippets/server-admin-beta.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"getPlayerProfile": {
"description": "Uses secrets and variables from dedicated server configuration files to further parameterize web requests. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-admin/serversecrets",
"prefix": ["mc"],
"body": [" const serverUrl = mcsa.variables.get('serverEndpoint');",
" const req = new HttpRequest(serverUrl + 'getPlayerProfile');",
" req.body = JSON.stringify({",
" playerId: 'johndoe',",
" });",
" const authTokenSec = mcsa.secrets.get('authtoken');",
" if (!authTokenSec) {",
" log('authtoken secret not defined.', -1);",
" return;",
" }",
" req.method = HttpRequestMethod.Post;",
" req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];",
" await http.request(req);"
]}
}
"getPlayerProfile": {
"description": "Uses secrets and variables from dedicated server configuration files to further parameterize web requests. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-admin/serversecrets",
"prefix": ["mc"],
"body": [
"// Note this code will only run on Bedrock Dedicated Server.",
" const serverUrl = mcsa.variables.get('serverEndpoint');",
" const req = new HttpRequest(serverUrl + 'getPlayerProfile');",
" req.body = JSON.stringify({",
" playerId: 'johndoe',",
" });",
" const authTokenSec = mcsa.secrets.get('authtoken');",
" if (!authTokenSec) {",
" log('authtoken secret not defined.', -1);",
" return;",
" }",
" req.method = HttpRequestMethod.Post;",
" req.headers = [new HttpHeader('Content-Type', 'application/json'), new HttpHeader('auth', authTokenSec)];",
" await http.request(req);"
]
}
}
10 changes: 3 additions & 7 deletions app/public/data/snippets/server-gametest-beta.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"description": "A simple mob test - the fox should attack the chicken. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-gametest/minecraft-server-gametest/register",
"prefix": ["mc"],
"body": [
"import { Test, register } from '@minecraft/server-gametest';",
"import { MinecraftEntityTypes } from '@minecraft/vanilla-data';",
"// Note this code will run in experimental worlds with the Beta APIs experiment, and supporting GameTest structures.",
"function simpleMobGameTest(test: Test) {",
" const attackerId = MinecraftEntityTypes.Fox;",
" const victimId = MinecraftEntityTypes.Chicken;",
Expand All @@ -23,8 +22,7 @@
"description": "Tests a failure case - phantoms should fly away from cats, but get captured by them. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-gametest/minecraft-server-gametest/register",
"prefix": ["mc"],
"body": [
"import { Test, register } from '@minecraft/server-gametest';",
"import { MinecraftEntityTypes } from '@minecraft/vanilla-data';",
"// Note this code will run in experimental worlds with the Beta APIs experiment, and supporting GameTest structures.",
"function phantomsShouldFlyFromCats(test: Test) {",
" test.spawn(MinecraftEntityTypes.Cat, { x: 4, y: 3, z: 3 });",
" test.spawn(MinecraftEntityTypes.Phantom, { x: 4, y: 3, z: 3 });",
Expand All @@ -39,9 +37,7 @@
"description": "Tests a roller coaster obstacle course. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-gametest/minecraft-server-gametest/register",
"prefix": ["mc"],
"body": [
"import { EntityComponentTypes } from '@minecraft/server';",
"import { Test, register } from '@minecraft/server-gametest';",
"import { MinecraftBlockTypes, MinecraftEntityTypes } from '@minecraft/vanilla-data';",
"// Note this code will run in experimental worlds with the Beta APIs experiment, and supporting GameTest structures.",
"function minibiomes(test: Test) {",
" const minecart = test.spawn(MinecraftEntityTypes.Minecart, { x: 9, y: 7, z: 7 });",
" const pig = test.spawn(MinecraftEntityTypes.Pig, { x: 9, y: 7, z: 7 });",
Expand Down
33 changes: 18 additions & 15 deletions app/public/data/snippets/server-net-beta.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"updateScore": {
"description": "Updates score on a local server. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-net/httprequest",
"prefix": ["mc"],
"body": [" const req = new HttpRequest('http://localhost:3000/updateScore');",
" req.body = JSON.stringify({",
" score: 22,",
" });",
" req.method = HttpRequestMethod.Post;",
" req.headers = [",
" new HttpHeader('Content-Type', 'application/json'),",
" new HttpHeader('auth', 'my-auth-token'),",
" ];",
" await http.request(req);"
]}
}
"updateScore": {
"description": "Updates score on a local server. See https://learn.microsoft.com/minecraft/creator/scriptapi/minecraft/server-net/httprequest",
"prefix": ["mc"],
"body": [
"// Note this code will only run on Bedrock Dedicated Server.",
" const req = new HttpRequest('http://localhost:3000/updateScore');",
" req.body = JSON.stringify({",
" score: 22,",
" });",
" req.method = HttpRequestMethod.Post;",
" req.headers = [",
" new HttpHeader('Content-Type', 'application/json'),",
" new HttpHeader('auth', 'my-auth-token'),",
" ];",
" await http.request(req);"
]
}
}
Loading

0 comments on commit 1ff1bb2

Please sign in to comment.