@minecraft/server 1.1.0-beta.1.19.60-preview.26 → 1.1.0-beta.1.19.70-preview.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +310 -649
- package/package.json +1 -1
- package/tests.ts +47 -41
package/package.json
CHANGED
package/tests.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import * as mc from '@minecraft/server';
|
|
3
3
|
|
|
4
|
-
export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
4
|
+
export function createExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
5
5
|
const overworld = mc.world.getDimension('overworld');
|
|
6
6
|
|
|
7
7
|
log('Creating an explosion of radius 10.');
|
|
8
8
|
overworld.createExplosion(targetLocation, 10);
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
11
|
+
export function createNoBlockExplosion(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
12
12
|
const overworld = mc.world.getDimension('overworld');
|
|
13
13
|
|
|
14
|
-
const explodeNoBlocksLoc =
|
|
15
|
-
Math.floor(targetLocation.x + 1),
|
|
16
|
-
Math.floor(targetLocation.y + 2),
|
|
17
|
-
Math.floor(targetLocation.z + 1),
|
|
18
|
-
|
|
14
|
+
const explodeNoBlocksLoc = {
|
|
15
|
+
x: Math.floor(targetLocation.x + 1),
|
|
16
|
+
y: Math.floor(targetLocation.y + 2),
|
|
17
|
+
z: Math.floor(targetLocation.z + 1),
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
log('Creating an explosion of radius 15 that does not break blocks.');
|
|
21
21
|
overworld.createExplosion(explodeNoBlocksLoc, 15, { breaksBlocks: false });
|
|
@@ -23,27 +23,31 @@ export function createNoBlockExplosion(log: (message: string, status?: number) =
|
|
|
23
23
|
|
|
24
24
|
export function createFireAndWaterExplosions(
|
|
25
25
|
log: (message: string, status?: number) => void,
|
|
26
|
-
targetLocation: mc.
|
|
26
|
+
targetLocation: mc.Vector3,
|
|
27
27
|
) {
|
|
28
28
|
const overworld = mc.world.getDimension('overworld');
|
|
29
29
|
|
|
30
|
-
const explosionLoc
|
|
30
|
+
const explosionLoc: mc.Vector3 = {
|
|
31
|
+
x: targetLocation.x + 0.5,
|
|
32
|
+
y: targetLocation.y + 0.5,
|
|
33
|
+
z: targetLocation.z + 0.5,
|
|
34
|
+
};
|
|
31
35
|
|
|
32
36
|
log('Creating an explosion of radius 15 that causes fire.');
|
|
33
37
|
overworld.createExplosion(explosionLoc, 15, { causesFire: true });
|
|
34
38
|
|
|
35
|
-
const belowWaterLoc =
|
|
39
|
+
const belowWaterLoc: mc.Vector3 = { x: targetLocation.x + 3, y: targetLocation.y + 1, z: targetLocation.z + 3 };
|
|
36
40
|
|
|
37
41
|
log('Creating an explosion of radius 10 that can go underwater.');
|
|
38
42
|
overworld.createExplosion(belowWaterLoc, 10, { allowUnderwater: true });
|
|
39
43
|
}
|
|
40
44
|
|
|
41
|
-
export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
45
|
+
export function itemStacks(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
42
46
|
const overworld = mc.world.getDimension('overworld');
|
|
43
47
|
|
|
44
|
-
const oneItemLoc =
|
|
45
|
-
const fiveItemsLoc =
|
|
46
|
-
const diamondPickaxeLoc =
|
|
48
|
+
const oneItemLoc: mc.Vector3 = { x: targetLocation.x + targetLocation.y + 3, y: 2, z: targetLocation.z + 1 };
|
|
49
|
+
const fiveItemsLoc: mc.Vector3 = { x: targetLocation.x + 1, y: targetLocation.y + 2, z: targetLocation.z + 1 };
|
|
50
|
+
const diamondPickaxeLoc: mc.Vector3 = { x: targetLocation.x + 2, y: targetLocation.y + 2, z: targetLocation.z + 4 };
|
|
47
51
|
|
|
48
52
|
const oneEmerald = new mc.ItemStack(mc.MinecraftItemTypes.emerald, 1, 0);
|
|
49
53
|
const onePickaxe = new mc.ItemStack(mc.MinecraftItemTypes.diamondPickaxe, 1, 0);
|
|
@@ -59,26 +63,28 @@ export function itemStacks(log: (message: string, status?: number) => void, targ
|
|
|
59
63
|
overworld.spawnItem(onePickaxe, diamondPickaxeLoc);
|
|
60
64
|
}
|
|
61
65
|
|
|
62
|
-
export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
66
|
+
export function quickFoxLazyDog(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
63
67
|
const overworld = mc.world.getDimension('overworld');
|
|
64
68
|
|
|
65
|
-
const fox = overworld.spawnEntity(
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
+
const fox = overworld.spawnEntity('minecraft:fox', {
|
|
70
|
+
x: targetLocation.x + 1,
|
|
71
|
+
y: targetLocation.y + 2,
|
|
72
|
+
z: targetLocation.z + 3,
|
|
73
|
+
});
|
|
69
74
|
fox.addEffect(mc.MinecraftEffectTypes.speed, 10, 20);
|
|
70
75
|
log('Created a fox.');
|
|
71
76
|
|
|
72
|
-
const wolf = overworld.spawnEntity(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
const wolf = overworld.spawnEntity('minecraft:wolf', {
|
|
78
|
+
x: targetLocation.x + 4,
|
|
79
|
+
y: targetLocation.y + 2,
|
|
80
|
+
z: targetLocation.z + 3,
|
|
81
|
+
});
|
|
76
82
|
wolf.addEffect(mc.MinecraftEffectTypes.slowness, 10, 20);
|
|
77
83
|
wolf.isSneaking = true;
|
|
78
84
|
log('Created a sneaking wolf.', 1);
|
|
79
85
|
}
|
|
80
86
|
|
|
81
|
-
export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
87
|
+
export function runEntityCreatedEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
82
88
|
// register a new function that is called when a new entity is created.
|
|
83
89
|
mc.world.events.entityCreate.subscribe((entityEvent: mc.EntityCreateEvent) => {
|
|
84
90
|
if (entityEvent && entityEvent.entity) {
|
|
@@ -89,19 +95,19 @@ export function runEntityCreatedEvent(log: (message: string, status?: number) =>
|
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
|
|
92
|
-
export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
98
|
+
export function createOldHorse(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
93
99
|
const overworld = mc.world.getDimension('overworld');
|
|
94
100
|
|
|
95
101
|
log("Create a horse and triggering the 'ageable_grow_up' event, ensuring the horse is created as an adult");
|
|
96
102
|
overworld.spawnEntity('minecraft:horse<minecraft:ageable_grow_up>', targetLocation);
|
|
97
103
|
}
|
|
98
104
|
|
|
99
|
-
export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
100
|
-
const pistonLoc =
|
|
101
|
-
Math.floor(targetLocation.x) + 1,
|
|
102
|
-
Math.floor(targetLocation.y) + 2,
|
|
103
|
-
Math.floor(targetLocation.z) + 1,
|
|
104
|
-
|
|
105
|
+
export function pistonEvent(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
106
|
+
const pistonLoc: mc.Vector3 = {
|
|
107
|
+
x: Math.floor(targetLocation.x) + 1,
|
|
108
|
+
y: Math.floor(targetLocation.y) + 2,
|
|
109
|
+
z: Math.floor(targetLocation.z) + 1,
|
|
110
|
+
};
|
|
105
111
|
|
|
106
112
|
mc.world.events.beforePistonActivate.subscribe((pistonEvent: mc.BeforePistonActivateEvent) => {
|
|
107
113
|
if (pistonEvent.piston.location.equals(pistonLoc)) {
|
|
@@ -111,7 +117,7 @@ export function pistonEvent(log: (message: string, status?: number) => void, tar
|
|
|
111
117
|
});
|
|
112
118
|
}
|
|
113
119
|
|
|
114
|
-
export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.
|
|
120
|
+
export function spawnItem(log: (message: string, status?: number) => void, targetLocation: mc.Vector3) {
|
|
115
121
|
const featherItem = new mc.ItemStack(mc.MinecraftItemTypes.feather, 1, 0);
|
|
116
122
|
|
|
117
123
|
overworld.spawnItem(featherItem, targetLocation);
|
|
@@ -120,7 +126,7 @@ export function spawnItem(log: (message: string, status?: number) => void, targe
|
|
|
120
126
|
|
|
121
127
|
export function testThatEntityIsFeatherItem(
|
|
122
128
|
log: (message: string, status?: number) => void,
|
|
123
|
-
targetLocation: mc.
|
|
129
|
+
targetLocation: mc.Vector3,
|
|
124
130
|
) {
|
|
125
131
|
const overworld = mc.world.getDimension('overworld');
|
|
126
132
|
|
|
@@ -161,13 +167,13 @@ export default class SampleManager {
|
|
|
161
167
|
tickCount = 0;
|
|
162
168
|
|
|
163
169
|
_availableFuncs: {
|
|
164
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
170
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
165
171
|
};
|
|
166
172
|
|
|
167
173
|
pendingFuncs: Array<{
|
|
168
174
|
name: string;
|
|
169
|
-
func: (log: (message: string, status?: number) => void, location: mc.
|
|
170
|
-
location: mc.
|
|
175
|
+
func: (log: (message: string, status?: number) => void, location: mc.Vector3) => void;
|
|
176
|
+
location: mc.Vector3;
|
|
171
177
|
}> = [];
|
|
172
178
|
|
|
173
179
|
gameplayLogger(message: string, status?: number) {
|
|
@@ -194,7 +200,7 @@ export default class SampleManager {
|
|
|
194
200
|
}
|
|
195
201
|
|
|
196
202
|
const nearbyBlockLoc = nearbyBlock.location;
|
|
197
|
-
const nearbyLoc =
|
|
203
|
+
const nearbyLoc: mc.Vector3 = { x: nearbyBlockLoc.x, y: nearbyBlockLoc.y + 1, z: nearbyBlockLoc.z };
|
|
198
204
|
|
|
199
205
|
const sampleId = message.substring(5).trim();
|
|
200
206
|
|
|
@@ -224,8 +230,8 @@ export default class SampleManager {
|
|
|
224
230
|
|
|
225
231
|
runSample(
|
|
226
232
|
sampleId: string,
|
|
227
|
-
snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
228
|
-
targetLocation: mc.
|
|
233
|
+
snippetFunctions: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>,
|
|
234
|
+
targetLocation: mc.Vector3,
|
|
229
235
|
) {
|
|
230
236
|
for (let i = snippetFunctions.length - 1; i >= 0; i--) {
|
|
231
237
|
this.pendingFuncs.push({ name: sampleId, func: snippetFunctions[i], location: targetLocation });
|
|
@@ -256,7 +262,7 @@ export default class SampleManager {
|
|
|
256
262
|
}
|
|
257
263
|
|
|
258
264
|
registerSamples(sampleSet: {
|
|
259
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
265
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
260
266
|
}) {
|
|
261
267
|
for (const sampleKey in sampleSet) {
|
|
262
268
|
if (sampleKey.length > 1 && sampleSet[sampleKey]) {
|
|
@@ -267,7 +273,7 @@ export default class SampleManager {
|
|
|
267
273
|
}
|
|
268
274
|
|
|
269
275
|
const mojangMinecraftFuncs: {
|
|
270
|
-
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.
|
|
276
|
+
[name: string]: Array<(log: (message: string, status?: number) => void, location: mc.Vector3) => void>;
|
|
271
277
|
} = {
|
|
272
278
|
runEntityCreatedEvent: [runEntityCreatedEvent, createOldHorse],
|
|
273
279
|
createOldHorse: [createOldHorse],
|