yeow-api 0.2.31 → 0.2.34
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/package.json +1 -1
- package/src/assets.ts +36 -29
- package/src/block.ts +13 -11
- package/src/command.ts +83 -64
- package/src/entity.ts +30 -27
- package/src/event.ts +257 -305
- package/src/fs.ts +64 -47
- package/src/global.d.ts +32 -0
- package/src/http.ts +58 -47
- package/src/index.ts +3 -1
- package/src/inventory.ts +33 -28
- package/src/lifecycle.ts +3 -0
- package/src/location.ts +24 -11
- package/src/player.ts +48 -41
- package/src/server.ts +7 -7
- package/src/task.ts +30 -20
- package/src/world.ts +70 -33
package/src/world.ts
CHANGED
|
@@ -1,41 +1,78 @@
|
|
|
1
1
|
import { call, post } from './task.js';
|
|
2
|
-
import { Location } from './location.js';
|
|
2
|
+
import { Location, LocationData } from './location.js';
|
|
3
3
|
import { Block } from './block.js';
|
|
4
4
|
|
|
5
|
+
interface WorldData {
|
|
6
|
+
name: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
5
9
|
export class World {
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
static get(name: string): World | null {
|
|
11
|
+
const d = call<WorldData>('world.get', { name });
|
|
12
|
+
return d ? new World(d.name) : null;
|
|
13
|
+
}
|
|
14
|
+
static getAll(): World[] {
|
|
15
|
+
return call<WorldData[]>('world.getAll', {}).map((r) => new World(r.name));
|
|
16
|
+
}
|
|
8
17
|
|
|
9
|
-
|
|
18
|
+
constructor(public readonly name: string) {}
|
|
10
19
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
get time(): number { return call<number>('world.getTime', { world: this.name }); }
|
|
21
|
+
set time(v: number) { call('world.setTime', { world: this.name, value: v }); }
|
|
22
|
+
get storm(): boolean { return call<boolean>('world.getStorm', { world: this.name }); }
|
|
23
|
+
set storm(v: boolean) { call('world.setStorm', { world: this.name, value: v }); }
|
|
24
|
+
get thundering(): boolean { return call<boolean>('world.getThundering', { world: this.name }); }
|
|
25
|
+
set thundering(v: boolean) { call('world.setThundering', { world: this.name, value: v }); }
|
|
26
|
+
get difficulty(): string { return call<string>('world.getDifficulty', { world: this.name }); }
|
|
27
|
+
set difficulty(v: string) { call('world.setDifficulty', { world: this.name, value: v }); }
|
|
28
|
+
get spawnLocation(): Location | null {
|
|
29
|
+
const r = call<LocationData>('world.getSpawnLocation', { world: this.name });
|
|
30
|
+
return r ? new Location(r.x, r.y, r.z, r.yaw, r.pitch) : null;
|
|
31
|
+
}
|
|
32
|
+
set spawnLocation(v: Location) { call('world.setSpawnLocation', { world: this.name, ...v.toObject() }); }
|
|
21
33
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
34
|
+
getHighestBlockY(x: number, z: number): number { return call<number>('world.getHighestBlockY', { world: this.name, x, z }); }
|
|
35
|
+
getGameRule(rule: string): string | null { return call<string | null>('world.getGameRule', { world: this.name, rule }); }
|
|
36
|
+
setGameRule(rule: string, value: string): Promise<boolean> { return post('world.setGameRule', { world: this.name, rule, value }); }
|
|
37
|
+
setGameRuleSync(rule: string, value: string): boolean { return call<boolean>('world.setGameRule', { world: this.name, rule, value }); }
|
|
38
|
+
getBiome(x: number, y: number, z: number): string { return call<string>('world.getBiome', { world: this.name, x, y, z }); }
|
|
39
|
+
getBlock(x: number, y: number, z: number): Block | null {
|
|
40
|
+
const r = call<{ x: number; y: number; z: number; type: string }>('world.getBlock', { world: this.name, x, y, z });
|
|
41
|
+
return r ? new Block(this.name, r.x, r.y, r.z, r.type) : null;
|
|
42
|
+
}
|
|
43
|
+
setBlock(x: number, y: number, z: number, blockType: string): Promise<void> {
|
|
44
|
+
return post('world.setBlock', { world: this.name, x, y, z, blockType });
|
|
45
|
+
}
|
|
46
|
+
setBlockSync(x: number, y: number, z: number, blockType: string): void {
|
|
47
|
+
call('world.setBlock', { world: this.name, x, y, z, blockType });
|
|
48
|
+
}
|
|
49
|
+
getEntities(): string[] { return call<string[]>('world.getEntities', { world: this.name }); }
|
|
50
|
+
getPlayers(): string[] { return call<string[]>('world.getPlayers', { world: this.name }); }
|
|
51
|
+
getNearbyEntities(x: number, y: number, z: number, radius: number): string[] {
|
|
52
|
+
return call<string[]>('world.getNearbyEntities', { world: this.name, x, y, z, radius });
|
|
53
|
+
}
|
|
54
|
+
dropItem(x: number, y: number, z: number, itemType: string, amount?: number): Promise<void> {
|
|
55
|
+
return post('world.dropItem', { world: this.name, x, y, z, itemType, amount });
|
|
56
|
+
}
|
|
57
|
+
dropItemSync(x: number, y: number, z: number, itemType: string, amount?: number): void {
|
|
58
|
+
call('world.dropItem', { world: this.name, x, y, z, itemType, amount });
|
|
59
|
+
}
|
|
60
|
+
strikeLightning(x: number, y: number, z: number): Promise<void> {
|
|
61
|
+
return post('world.strikeLightning', { world: this.name, x, y, z });
|
|
62
|
+
}
|
|
63
|
+
strikeLightningSync(x: number, y: number, z: number): void {
|
|
64
|
+
call('world.strikeLightning', { world: this.name, x, y, z });
|
|
65
|
+
}
|
|
66
|
+
strikeLightningEffect(x: number, y: number, z: number): Promise<void> {
|
|
67
|
+
return post('world.strikeLightningEffect', { world: this.name, x, y, z });
|
|
68
|
+
}
|
|
69
|
+
strikeLightningEffectSync(x: number, y: number, z: number): void {
|
|
70
|
+
call('world.strikeLightningEffect', { world: this.name, x, y, z });
|
|
71
|
+
}
|
|
72
|
+
createExplosion(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean): Promise<void> {
|
|
73
|
+
return post('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks });
|
|
74
|
+
}
|
|
75
|
+
createExplosionSync(x: number, y: number, z: number, power?: number, fire?: boolean, breaks?: boolean): void {
|
|
76
|
+
call('world.createExplosion', { world: this.name, x, y, z, power, setFire: fire, breakBlocks: breaks });
|
|
77
|
+
}
|
|
41
78
|
}
|