Skip to content

Commit ee8eb98

Browse files
committed
2 parents 19e5548 + 586d57b commit ee8eb98

20 files changed

+351
-497
lines changed

.github/workflows/gametest.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: gametest
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
gametest:
7+
name: debug
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v3
13+
14+
- name: npm install
15+
run: npm install
16+
17+
- name: tsc
18+
run: tsc

.github/workflows/lint-md.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: markdown-link-check
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
markdown-link-check:
7+
name: action
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout
11+
uses: actions/checkout@v2
12+
13+
- name: Markdown links check
14+
uses: ruzickap/action-my-markdown-link-checker@v1

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules/
1+
node_modules/
2+
package-lock.json

mojang-minecraft-ui/ModalForm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ ModalForm.icon("textures/blocks/bedrock");
2525
ModalForm.slider("slider", 0, 100, 50);
2626

2727
// Adds a textbox to the form.
28-
ModalForm.textField("text field");
28+
ModalForm.textField("text field", "text");
2929

3030
// This builder method sets the title for the modal dialog.
3131
ModalForm.title("Modal Form");

mojang-net/http.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { http, HttpRequest } from "mojang-net";
1+
import { http, HttpHeader, HttpRequest, HttpRequestMethod } from "mojang-net";
22

33
// simple http get url random get function
44
http.get("https://api.ipify.org?format=json").then(res => {
@@ -17,8 +17,8 @@ http.get("https://api.ipify.org?format=json").then(res => {
1717
const request = new HttpRequest("https://api.github.com/repos/MicrosoftDocs/minecraft-creator/git/trees/main?recursive=1");
1818

1919
request.uri = "https://api.github.com/repos/MicrosoftDocs/minecraft-creator/git/trees/main?recursive=1";
20-
request.headers = { "User-Agent": null };
21-
request.method = "GET";
20+
request.headers = [new HttpHeader("User-Agent", null)];
21+
request.method = HttpRequestMethod.GET;
2222

2323
http.request(request).then(res => {
2424
// Do something with the response.

package-lock.json

Lines changed: 0 additions & 108 deletions
This file was deleted.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
22
"dependencies": {
3-
"@types/mojang-gametest": "^0.1.5",
4-
"@types/mojang-minecraft": "^0.1.6",
5-
"@types/mojang-minecraft-server-admin": "^0.1.0",
6-
"@types/mojang-minecraft-ui": "^0.1.0",
7-
"@types/mojang-net": "^0.1.0"
83
},
94
"name": "gametest-db",
105
"description": "this repository is filled with code examples for variables in GameTest Framework module",
@@ -25,6 +20,12 @@
2520
"homepage": "https://github.com/JaylyDev/GametestDB#readme",
2621
"type": "module",
2722
"devDependencies": {
28-
"uuid": "^8.3.2"
23+
"uuid": "^8.3.2",
24+
"@types/mojang-gametest": "^0.1.5",
25+
"@types/mojang-minecraft": "^0.1.6",
26+
"@types/mojang-minecraft-server-admin": "^0.1.0",
27+
"@types/mojang-minecraft-ui": "^0.1.0",
28+
"@types/mojang-net": "^0.1.0",
29+
"@types/node": "^18.0.3"
2930
}
3031
}

scripts/another-form.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// https://discord.com/channels/523663022053392405/854033525546942464/988466192383615066
2+
import { world } from "mojang-minecraft";
23
import { ActionFormData } from "mojang-minecraft-ui"
34

5+
const player = [...world.getPlayers()][0];
46
new ActionFormData()
57
.title("First form")
68
.body("This is first form")
@@ -9,6 +11,9 @@ new ActionFormData()
911
if (r.selection == 0) anotherUI(player)
1012
});
1113

14+
/**
15+
* @param {import("mojang-minecraft").Player} player
16+
*/
1217
function anotherUI(player) {
1318
// This function ONLY hold one form
1419
// Not accessing another form

scripts/compass-prompt.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { world } from "mojang-minecraft"
1+
import { Player, world } from "mojang-minecraft"
22
import { ActionFormData } from "mojang-minecraft-ui"
33

44
const gui = new ActionFormData()
@@ -12,6 +12,7 @@ gui.button('§l§eMoney Transactions')
1212

1313
world.events.beforeItemUse.subscribe(data => {
1414
const source = data.source
15+
if (!(source instanceof Player)) return;
1516
if (data.item.id === 'minecraft:compass') gui.show(source).then(result => {
1617
if (result.isCanceled) console.warn('GUI was canceled')
1718
if (result.selection === 0) source.runCommand('give @s diamond 1')

scripts/cps_counter.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { MinecraftEntityTypes as e, world as t } from "mojang-minecraft";
2-
t.events.entityHit.subscribe(function ({ entity: t }) {
3-
t.id === e.player.id &&
4-
(t.clicks || (t.clicks = []),
5-
t.clicks.push({ timestamp: new Date().getTime() }));
1+
import { MinecraftEntityTypes, world } from "mojang-minecraft";
2+
world.events.entityHit.subscribe(function ({ entity }) {
3+
entity.id === MinecraftEntityTypes.player.id &&
4+
(entity["clicks"] || (entity["clicks"] = []),
5+
entity["clicks"].push({ timestamp: new Date().getTime() }));
66
}),
7-
t.events.tick.subscribe(() => {
7+
world.events.tick.subscribe(() => {
88
const e = new Date().getTime();
9-
for (const i of t.getPlayers()) {
10-
i.clicks || (i.clicks = []);
11-
const t = i.clicks.filter(({ timestamp: t }) => e - 1e3 < t);
12-
(i.clicks = t), i.onScreenDisplay.setActionBar(`CPS: ${t.length}`);
9+
for (const i of world.getPlayers()) {
10+
i["clicks"] || (i["clicks"] = []);
11+
const t = i["clicks"].filter(({ timestamp: t }) => e - 1e3 < t);
12+
(i["clicks"] = t), i.onScreenDisplay.setActionBar(`CPS: ${t.length}`);
1313
}
1414
});

scripts/entityHit.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ world.events.entityHit.subscribe((evd) => {
1010
/**
1111
* @type {EntityHealthComponent}
1212
*/
13+
// @ts-ignore
1314
const h = ent.getComponent('health');
1415
if (!h) return;
1516
h.setCurrent(h.current - 100);

scripts/getScore.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// https://discord.com/channels/862462061594017802/944054708123861002/988871809816465479
2-
import { world } from "mojang-minecraft";
2+
import { Entity, world } from "mojang-minecraft";
3+
4+
const player = [...world.getPlayers()][0];
35
const myVar = getScore('my Objective', player, true)
46

57
/**

scripts/json-stringify.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Native JSON stringify function
3-
* @type {(value: any, replacer?: (this: any, key: string, value: any) => any, space?: string | number): string}
43
*/
54
const __stringify = JSON.stringify;
65

@@ -21,8 +20,8 @@ function cloneJSON(obj) {
2120
return cloneA;
2221
}
2322
var cloneO = {};
24-
for (var i in obj) {
25-
cloneO[i] = cloneJSON(obj[i]);
23+
for (var e in obj) {
24+
cloneO[e] = cloneJSON(obj[e]);
2625
}
2726
return cloneO;
2827
};
@@ -41,4 +40,5 @@ function JSONStringify (value, replacer, space) {
4140
return __stringify(cloneJSON(value), replacer, space);
4241
};
4342

43+
// @ts-ignore
4444
JSON.stringify = JSONStringify;

scripts/sell-items.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const sell = (player) => {
2121
/**
2222
* @type {PlayerInventoryComponentContainer} The player's inventory container
2323
*/
24+
// @ts-ignore
2425
const inv = player.getComponent('inventory').container, { size } = inv
2526
const voidSlot = new ItemStack(Items.get('minecraft:air'), 1, 0)
2627
let amount = 0;

scripts/timers/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/timers/timers-test.js

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)