forked from JaylyDev/ScriptAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (31 loc) · 1.21 KB
/
index.js
File metadata and controls
31 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Script example for ScriptAPI
// Author: Jayly <https://github.com/JaylyDev>
// Project: https://github.com/JaylyDev/ScriptAPI
/**
* @license MIT
* @author JaylyMC
* @project https://github.com/JaylyDev/GametestDB/
*/
import * as MinecraftServer from "@minecraft/server";
import * as GameTest from "@minecraft/server-gametest";
;
/**
* Spawns a simulated player
* @param target The player the simulated player is going to spawn at
* @param callback Implementation of the simulated player
*/
export function SpawnSimulatedPlayer(target, callback) {
const testClassName = "Jayly";
const testName = "SpawnSimulatedPlayer";
if (!(target instanceof MinecraftServer.Player))
throw new TypeError("Native type conversion failed.");
GameTest.registerAsync(testClassName, testName, async function (test) {
let simulatedplayer = test.spawnSimulatedPlayer({ x: 0, y: 1, z: 0, });
simulatedplayer.despawn = () => test.removeSimulatedPlayer(simulatedplayer);
callback(simulatedplayer);
})
.structureName("DebugTests:always_succeed")
.tag(GameTest.Tags.suiteDefault)
.maxTicks(0x7fffffff);
target.runCommandAsync(`gametest run ${testClassName}:${testName}`);
}