yeow-api 0.2.59 → 0.2.101

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yeow-api",
3
- "version": "0.2.59",
3
+ "version": "0.2.101",
4
4
  "description": "Yeow API",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
package/src/chunk.ts ADDED
@@ -0,0 +1,122 @@
1
+ import { call, post } from './task.js';
2
+
3
+ export interface ChunkData {
4
+ x: number;
5
+ z: number;
6
+ world: string;
7
+ }
8
+
9
+ /** 模块级缓存:方块 key 列表(= Java 侧索引基准,运行时内稳定)。 */
10
+ let _blocksCache: string[] | null = null;
11
+
12
+ async function ensureBlocks(): Promise<string[]> {
13
+ if (_blocksCache) return _blocksCache;
14
+ const blocks = await post<string[]>('server.getBlocks', {});
15
+ _blocksCache = blocks;
16
+ return blocks;
17
+ }
18
+
19
+ function ensureBlocksSync(): string[] {
20
+ if (_blocksCache) return _blocksCache;
21
+ const blocks = call<string[]>('server.getBlocks', {});
22
+ _blocksCache = blocks;
23
+ return blocks;
24
+ }
25
+
26
+ /** base64(little-endian short[]) → Uint16Array:直接视图,零拷贝零遍历。 */
27
+ function decodeShortArray(b64: string): Uint16Array {
28
+ const bytes = Uint8Array.fromBase64(b64);
29
+ return new Uint16Array(bytes.buffer, bytes.byteOffset, bytes.length >>> 1);
30
+ }
31
+
32
+ /**
33
+ * 完整区块快照(3D):方块类型索引数组,与 `getBlocks()` 的数组下标对应。
34
+ * 索引仅当前运行时有效(重启后可能变化),不可持久化。
35
+ */
36
+ export class ChunkSnapshot {
37
+ constructor(
38
+ readonly data: Uint16Array,
39
+ readonly minY: number,
40
+ readonly height: number,
41
+ readonly blocks: string[],
42
+ ) {}
43
+
44
+ /** 绝对高度 y 处的方块 key(越界/未知索引回退 minecraft:air)。 */
45
+ getBlock(x: number, y: number, z: number): string {
46
+ const ry = y - this.minY;
47
+ if (x < 0 || x > 15 || z < 0 || z > 15 || ry < 0 || ry >= this.height) return 'minecraft:air';
48
+ return this.blocks[this.data[(ry * 16 + z) * 16 + x]] ?? 'minecraft:air';
49
+ }
50
+
51
+ /** 绝对高度 y 处的原始方块索引。 */
52
+ getBlockIndex(x: number, y: number, z: number): number {
53
+ const ry = y - this.minY;
54
+ if (x < 0 || x > 15 || z < 0 || z > 15 || ry < 0 || ry >= this.height) return 0;
55
+ return this.data[(ry * 16 + z) * 16 + x];
56
+ }
57
+
58
+ static async fromRaw(raw: { data: string; minY: number; height: number }): Promise<ChunkSnapshot> {
59
+ return new ChunkSnapshot(decodeShortArray(raw.data), raw.minY, raw.height, await ensureBlocks());
60
+ }
61
+
62
+ static fromRawSync(raw: { data: string; minY: number; height: number }): ChunkSnapshot {
63
+ return new ChunkSnapshot(decodeShortArray(raw.data), raw.minY, raw.height, ensureBlocksSync());
64
+ }
65
+ }
66
+
67
+ /**
68
+ * 顶部方块快照(2D,256 元素):每列最高非空气方块的类型索引,顺序 z 外层 → x 内层。
69
+ * 索引仅当前运行时有效,不可持久化。
70
+ */
71
+ export class ChunkTopSnapshot {
72
+ constructor(
73
+ readonly data: Uint16Array,
74
+ readonly blocks: string[],
75
+ ) {}
76
+
77
+ getTop(x: number, z: number): string {
78
+ if (x < 0 || x > 15 || z < 0 || z > 15) return 'minecraft:air';
79
+ return this.blocks[this.data[z * 16 + x]] ?? 'minecraft:air';
80
+ }
81
+
82
+ getTopIndex(x: number, z: number): number {
83
+ if (x < 0 || x > 15 || z < 0 || z > 15) return 0;
84
+ return this.data[z * 16 + x];
85
+ }
86
+
87
+ static async fromRaw(raw: { data: string }): Promise<ChunkTopSnapshot> {
88
+ return new ChunkTopSnapshot(decodeShortArray(raw.data), await ensureBlocks());
89
+ }
90
+
91
+ static fromRawSync(raw: { data: string }): ChunkTopSnapshot {
92
+ return new ChunkTopSnapshot(decodeShortArray(raw.data), ensureBlocksSync());
93
+ }
94
+ }
95
+
96
+ export class Chunk {
97
+ constructor(
98
+ public readonly x: number,
99
+ public readonly z: number,
100
+ public readonly world: string,
101
+ ) {}
102
+
103
+ static from(d: ChunkData): Chunk {
104
+ return new Chunk(d.x, d.z, d.world);
105
+ }
106
+
107
+ /** 完整方块快照(16×16×世界高度,y 外层 → z → x)。重量级操作,适合低频/批量场景。 */
108
+ getSnapshot(): Promise<ChunkSnapshot> {
109
+ return post<{ data: string; minY: number; height: number }>('chunk.getSnapshot', { world: this.world, x: this.x, z: this.z }).then(ChunkSnapshot.fromRaw);
110
+ }
111
+ getSnapshotSync(): ChunkSnapshot {
112
+ return ChunkSnapshot.fromRawSync(call<{ data: string; minY: number; height: number }>('chunk.getSnapshot', { world: this.world, x: this.x, z: this.z }));
113
+ }
114
+
115
+ /** 顶部方块快照(256 元素,每列最高非空气方块,z 外层 → x 内层)。 */
116
+ getTopSnapshot(): Promise<ChunkTopSnapshot> {
117
+ return post<{ data: string }>('chunk.getTopSnapshot', { world: this.world, x: this.x, z: this.z }).then(ChunkTopSnapshot.fromRaw);
118
+ }
119
+ getTopSnapshotSync(): ChunkTopSnapshot {
120
+ return ChunkTopSnapshot.fromRawSync(call<{ data: string }>('chunk.getTopSnapshot', { world: this.world, x: this.x, z: this.z }));
121
+ }
122
+ }
package/src/entity.ts CHANGED
@@ -1,6 +1,15 @@
1
1
  import { call, post } from './task.js';
2
2
  import { Location, LocationData } from './location.js';
3
3
 
4
+ export interface BoundingBox {
5
+ minX: number;
6
+ minY: number;
7
+ minZ: number;
8
+ maxX: number;
9
+ maxY: number;
10
+ maxZ: number;
11
+ }
12
+
4
13
  export class Entity {
5
14
  static get(uuid: string): Promise<Entity | null> {
6
15
  return post<{ uuid: string }>('entity.get', { uuid }).then((d) => (d ? new Entity(d.uuid) : null));
@@ -67,6 +76,11 @@ export class Entity {
67
76
  get vehicle(): string | null { return call<string | null>('entity.getVehicle', { uuid: this.uuid }); }
68
77
  getVehicle(): Promise<string | null> { return post<string | null>('entity.getVehicle', { uuid: this.uuid }); }
69
78
 
79
+ get boundingBox(): BoundingBox {
80
+ return call<BoundingBox>('entity.getBoundingBox', { uuid: this.uuid });
81
+ }
82
+ getBoundingBox(): Promise<BoundingBox> { return post<BoundingBox>('entity.getBoundingBox', { uuid: this.uuid }); }
83
+
70
84
  remove(): Promise<void> { return post('entity.remove', { uuid: this.uuid }); }
71
85
  removeSync(): void { call('entity.remove', { uuid: this.uuid }); }
72
86
  teleport(loc: Location): Promise<void> { return post('entity.teleport', { uuid: this.uuid, ...loc.toObject() }); }
package/src/event.ts CHANGED
@@ -168,6 +168,18 @@ export interface PlayerItemConsumeEvent {
168
168
  itemType: string;
169
169
  cancelled?: boolean;
170
170
  }
171
+ export interface PlayerAdvancementDoneEvent {
172
+ player: Player;
173
+ advancement: string;
174
+ }
175
+ export interface PlayerToggleSneakEvent {
176
+ player: Player;
177
+ sneaking: boolean;
178
+ }
179
+ export interface PlayerToggleFlightEvent {
180
+ player: Player;
181
+ flying: boolean;
182
+ }
171
183
  export interface EntityExplodeEvent {
172
184
  entity: string;
173
185
  entityType: string;
@@ -268,6 +280,9 @@ type EventMap = {
268
280
  playerExpChange: PlayerExpChangeEvent;
269
281
  playerLevelChange: PlayerLevelChangeEvent;
270
282
  playerGameModeChange: PlayerGameModeChangeEvent;
283
+ playerAdvancementDone: PlayerAdvancementDoneEvent;
284
+ playerToggleSneak: PlayerToggleSneakEvent;
285
+ playerToggleFlight: PlayerToggleFlightEvent;
271
286
  foodLevelChange: FoodLevelChangeEvent;
272
287
  entityDamage: EntityDamageEvent;
273
288
  entityDeath: EntityDeathEvent;
package/src/fs.ts CHANGED
@@ -1,3 +1,5 @@
1
+ type FsLevel = 'plugin' | 'server' | 'outer';
2
+
1
3
  function _sendFs(payload: Record<string, unknown>): unknown {
2
4
  const r = $send('fs', payload);
3
5
  if (r == null) return undefined;
@@ -15,88 +17,132 @@ function _sendFsAsync(payload: Record<string, unknown>): Promise<unknown> {
15
17
  });
16
18
  }
17
19
 
18
- export async function readFile(path: string): Promise<string> {
19
- const r = await _sendFsAsync({ t: 'readFile', p: { path } }) as { data: string };
20
- return r.data;
21
- }
22
- export function readFileSync(path: string): string {
23
- return (_sendFs({ t: 'readFile', p: { path } }) as { data: string }).data;
24
- }
20
+ /** fs 级别(plugin/server/outer)生成全套文件操作。 */
21
+ function _makeFs(level: FsLevel) {
22
+ const t = (op: string) => `${level}.${op}`;
25
23
 
26
- export async function readFileBase64(path: string): Promise<string> {
27
- const r = await _sendFsAsync({ t: 'readBase64', p: { path } }) as { data: string };
28
- return r.data;
29
- }
30
- export function readFileBase64Sync(path: string): string {
31
- return (_sendFs({ t: 'readBase64', p: { path } }) as { data: string }).data;
32
- }
24
+ async function readFile(path: string): Promise<string> {
25
+ const r = await _sendFsAsync({ t: t('readFile'), p: { path } }) as { data: string };
26
+ return r.data;
27
+ }
28
+ function readFileSync(path: string): string {
29
+ return (_sendFs({ t: t('readFile'), p: { path } }) as { data: string }).data;
30
+ }
33
31
 
34
- export async function writeFile(path: string, data: string): Promise<void> {
35
- await _sendFsAsync({ t: 'writeFile', p: { path, data } });
36
- }
37
- export function writeFileSync(path: string, data: string): void {
38
- _sendFs({ t: 'writeFile', p: { path, data } });
39
- }
32
+ async function readFileBase64(path: string): Promise<string> {
33
+ const r = await _sendFsAsync({ t: t('readBase64'), p: { path } }) as { data: string };
34
+ return r.data;
35
+ }
36
+ function readFileBase64Sync(path: string): string {
37
+ return (_sendFs({ t: t('readBase64'), p: { path } }) as { data: string }).data;
38
+ }
40
39
 
41
- export async function writeFileBase64(path: string, data: string): Promise<void> {
42
- await _sendFsAsync({ t: 'writeBase64', p: { path, data } });
43
- }
44
- export function writeFileBase64Sync(path: string, data: string): void {
45
- _sendFs({ t: 'writeBase64', p: { path, data } });
46
- }
40
+ async function writeFile(path: string, data: string): Promise<void> {
41
+ await _sendFsAsync({ t: t('writeFile'), p: { path, data } });
42
+ }
43
+ function writeFileSync(path: string, data: string): void {
44
+ _sendFs({ t: t('writeFile'), p: { path, data } });
45
+ }
47
46
 
48
- export async function appendFile(path: string, data: string): Promise<void> {
49
- await _sendFsAsync({ t: 'appendFile', p: { path, data } });
50
- }
51
- export function appendFileSync(path: string, data: string): void {
52
- _sendFs({ t: 'appendFile', p: { path, data } });
53
- }
47
+ async function writeFileBase64(path: string, data: string): Promise<void> {
48
+ await _sendFsAsync({ t: t('writeBase64'), p: { path, data } });
49
+ }
50
+ function writeFileBase64Sync(path: string, data: string): void {
51
+ _sendFs({ t: t('writeBase64'), p: { path, data } });
52
+ }
54
53
 
55
- export async function exists(path: string): Promise<boolean> {
56
- const r = await _sendFsAsync({ t: 'exists', p: { path } });
57
- return r === true || String(r) === 'true';
58
- }
59
- export function existsSync(path: string): boolean {
60
- const r = _sendFs({ t: 'exists', p: { path } });
61
- return r === true || String(r) === 'true';
62
- }
54
+ async function appendFile(path: string, data: string): Promise<void> {
55
+ await _sendFsAsync({ t: t('appendFile'), p: { path, data } });
56
+ }
57
+ function appendFileSync(path: string, data: string): void {
58
+ _sendFs({ t: t('appendFile'), p: { path, data } });
59
+ }
63
60
 
64
- export async function isDirectory(path: string): Promise<boolean> {
65
- const r = await _sendFsAsync({ t: 'isDirectory', p: { path } });
66
- return r === true || String(r) === 'true';
67
- }
68
- export function isDirectorySync(path: string): boolean {
69
- const r = _sendFs({ t: 'isDirectory', p: { path } });
70
- return r === true || String(r) === 'true';
71
- }
61
+ async function exists(path: string): Promise<boolean> {
62
+ const r = await _sendFsAsync({ t: t('exists'), p: { path } });
63
+ return r === true || String(r) === 'true';
64
+ }
65
+ function existsSync(path: string): boolean {
66
+ const r = _sendFs({ t: t('exists'), p: { path } });
67
+ return r === true || String(r) === 'true';
68
+ }
72
69
 
73
- export async function deleteFile(path: string): Promise<boolean> {
74
- const r = await _sendFsAsync({ t: 'delete', p: { path } });
75
- return r === true || String(r) === 'true';
76
- }
77
- export function deleteFileSync(path: string): boolean {
78
- const r = _sendFs({ t: 'delete', p: { path } });
79
- return r === true || String(r) === 'true';
80
- }
70
+ async function isDirectory(path: string): Promise<boolean> {
71
+ const r = await _sendFsAsync({ t: t('isDirectory'), p: { path } });
72
+ return r === true || String(r) === 'true';
73
+ }
74
+ function isDirectorySync(path: string): boolean {
75
+ const r = _sendFs({ t: t('isDirectory'), p: { path } });
76
+ return r === true || String(r) === 'true';
77
+ }
81
78
 
82
- export async function mkdir(path: string): Promise<void> {
83
- await _sendFsAsync({ t: 'mkdir', p: { path } });
84
- }
85
- export function mkdirSync(path: string): void {
86
- _sendFs({ t: 'mkdir', p: { path } });
87
- }
79
+ async function deleteFile(path: string): Promise<boolean> {
80
+ const r = await _sendFsAsync({ t: t('delete'), p: { path } });
81
+ return r === true || String(r) === 'true';
82
+ }
83
+ function deleteFileSync(path: string): boolean {
84
+ const r = _sendFs({ t: t('delete'), p: { path } });
85
+ return r === true || String(r) === 'true';
86
+ }
88
87
 
89
- export async function list(path: string): Promise<string[]> {
90
- return await _sendFsAsync({ t: 'list', p: { path } }) as string[];
91
- }
92
- export function listSync(path: string): string[] {
93
- return _sendFs({ t: 'list', p: { path } }) as string[];
88
+ async function mkdir(path: string): Promise<void> {
89
+ await _sendFsAsync({ t: t('mkdir'), p: { path } });
90
+ }
91
+ function mkdirSync(path: string): void {
92
+ _sendFs({ t: t('mkdir'), p: { path } });
93
+ }
94
+
95
+ async function list(path: string): Promise<string[]> {
96
+ return await _sendFsAsync({ t: t('list'), p: { path } }) as string[];
97
+ }
98
+ function listSync(path: string): string[] {
99
+ return _sendFs({ t: t('list'), p: { path } }) as string[];
100
+ }
101
+
102
+ async function systemPaths(): Promise<{ home: string; desktop: string; temp: string }> {
103
+ return await _sendFsAsync({ t: t('systemPaths') }) as { home: string; desktop: string; temp: string };
104
+ }
105
+ function systemPathsSync(): { home: string; desktop: string; temp: string } {
106
+ return _sendFs({ t: t('systemPaths') }) as { home: string; desktop: string; temp: string };
107
+ }
108
+
109
+ return {
110
+ readFile, readFileSync, readFileBase64, readFileBase64Sync,
111
+ writeFile, writeFileSync, writeFileBase64, writeFileBase64Sync,
112
+ appendFile, appendFileSync,
113
+ exists, existsSync, isDirectory, isDirectorySync,
114
+ deleteFile, deleteFileSync, mkdir, mkdirSync, list, listSync,
115
+ // systemPaths 仅 outer 级提供(fs.outer.systemPaths)
116
+ ...(level === 'outer' ? { systemPaths, systemPathsSync } : {}),
117
+ };
94
118
  }
95
119
 
120
+ // fs.* 为 plugin 级别(插件数据目录 plugins/<name>/,无需声明权限);
121
+ // fs.server.* / fs.outer.* 需在 yeow.config.json 声明 fs:server.* / fs:outer.*。
96
122
  export const fs = {
97
- readFile, readFileSync, readFileBase64, readFileBase64Sync,
98
- writeFile, writeFileSync, writeFileBase64, writeFileBase64Sync,
99
- appendFile, appendFileSync,
100
- exists, existsSync, isDirectory, isDirectorySync,
101
- deleteFile, deleteFileSync, mkdir, mkdirSync, list, listSync,
123
+ ..._makeFs('plugin'),
124
+ server: _makeFs('server'),
125
+ outer: _makeFs('outer'),
102
126
  };
127
+
128
+ // 顶层函数 = plugin 级别(与 fs.* 一致)
129
+ export const readFile = fs.readFile;
130
+ export const readFileSync = fs.readFileSync;
131
+ export const readFileBase64 = fs.readFileBase64;
132
+ export const readFileBase64Sync = fs.readFileBase64Sync;
133
+ export const writeFile = fs.writeFile;
134
+ export const writeFileSync = fs.writeFileSync;
135
+ export const writeFileBase64 = fs.writeFileBase64;
136
+ export const writeFileBase64Sync = fs.writeFileBase64Sync;
137
+ export const appendFile = fs.appendFile;
138
+ export const appendFileSync = fs.appendFileSync;
139
+ export const exists = fs.exists;
140
+ export const existsSync = fs.existsSync;
141
+ export const isDirectory = fs.isDirectory;
142
+ export const isDirectorySync = fs.isDirectorySync;
143
+ export const deleteFile = fs.deleteFile;
144
+ export const deleteFileSync = fs.deleteFileSync;
145
+ export const mkdir = fs.mkdir;
146
+ export const mkdirSync = fs.mkdirSync;
147
+ export const list = fs.list;
148
+ export const listSync = fs.listSync;
package/src/global.d.ts CHANGED
@@ -28,8 +28,12 @@ declare global {
28
28
  { cbId: string; handler: Function; manualRelease: boolean }[]
29
29
  >
30
30
  | undefined;
31
+ }
31
32
 
32
- function uint8ArrayToBase64(buffer: ArrayBuffer): string;
33
- function base64ToUint8Array(base64: string): ArrayBuffer;
33
+ // yeow-dev:构建期虚拟模块(由 Yeow 构建器按 importer 所属依赖项注入命名空间)。
34
+ // 插件未安装 yeow-dev 时此声明生效;类型与实际构建行为一致。
35
+ declare module 'yeow-dev' {
36
+ export function getAssetsPath(path: string): string;
34
37
  }
38
+
35
39
  export {};
package/src/index.ts CHANGED
@@ -4,7 +4,10 @@ export { call } from './task.js';
4
4
  export { Location } from './location.js';
5
5
  export { Player } from './player.js';
6
6
  export { World } from './world.js';
7
+ export { Chunk, ChunkSnapshot, ChunkTopSnapshot } from './chunk.js';
8
+ export type { ChunkData } from './chunk.js';
7
9
  export { Entity, LivingEntity } from './entity.js';
10
+ export type { BoundingBox } from './entity.js';
8
11
  export { Block } from './block.js';
9
12
  export { Inventory } from './inventory.js';
10
13
  export { registerCommand } from './command.js';
@@ -14,6 +17,7 @@ export type {
14
17
  PlayerJoinEvent, PlayerQuitEvent, PlayerChatEvent, PlayerMoveEvent,
15
18
  PlayerInteractEvent, PlayerCommandEvent, PlayerDeathEvent, PlayerRespawnEvent,
16
19
  PlayerTeleportEvent, PlayerItemConsumeEvent,
20
+ PlayerAdvancementDoneEvent, PlayerToggleSneakEvent, PlayerToggleFlightEvent,
17
21
  PlayerDropItemEvent, PlayerPickupItemEvent, PlayerBucketFillEvent, PlayerBucketEmptyEvent,
18
22
  PlayerExpChangeEvent, PlayerLevelChangeEvent, PlayerGameModeChangeEvent, FoodLevelChangeEvent,
19
23
  EntityDamageEvent, EntityDeathEvent, EntitySpawnEvent, EntityExplodeEvent,
@@ -41,7 +45,6 @@ export {
41
45
  export { assets, read as assetsRead, readSync as assetsReadSync,
42
46
  readBase64 as assetsReadBase64, readBase64Sync as assetsReadBase64Sync,
43
47
  extract as assetsExtract, extractSync as assetsExtractSync } from './assets.js';
44
- export { getAssetsPath } from './assets-path.js';
45
48
  export { path } from './path.js';
46
49
  export { listen, respond, close, request } from './http.js';
47
50
  export { logError } from './log-error.js';
package/src/player.ts CHANGED
@@ -65,6 +65,19 @@ export class Player {
65
65
  isFlyingAsync(): Promise<boolean> { return post<boolean>('player.isFlying', { uuid: this.uuid }); }
66
66
  setFlying(v: boolean): Promise<void> { return post('player.setFlying', { uuid: this.uuid, value: v }); }
67
67
 
68
+ get isSneaking(): boolean { return call<boolean>('player.isSneaking', { uuid: this.uuid }); }
69
+ isSneakingAsync(): Promise<boolean> { return post<boolean>('player.isSneaking', { uuid: this.uuid }); }
70
+ get isSprinting(): boolean { return call<boolean>('player.isSprinting', { uuid: this.uuid }); }
71
+ isSprintingAsync(): Promise<boolean> { return post<boolean>('player.isSprinting', { uuid: this.uuid }); }
72
+
73
+ get bedLocation(): Location | null {
74
+ const r = call<LocationData>('player.getBedLocation', { uuid: this.uuid });
75
+ return r ? Location.from(r) : null;
76
+ }
77
+ getBedLocation(): Promise<Location | null> {
78
+ return post<LocationData>('player.getBedLocation', { uuid: this.uuid }).then((r) => (r ? Location.from(r) : null));
79
+ }
80
+
68
81
  get allowFlight(): boolean { return call<boolean>('player.getAllowFlight', { uuid: this.uuid }); }
69
82
  set allowFlight(v: boolean) { call('player.setAllowFlight', { uuid: this.uuid, value: v }); }
70
83
  getAllowFlight(): Promise<boolean> { return post<boolean>('player.getAllowFlight', { uuid: this.uuid }); }
package/src/world.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { call, post } from './task.js';
2
2
  import { Location, LocationData } from './location.js';
3
3
  import { Block } from './block.js';
4
+ import { Chunk, ChunkData } from './chunk.js';
4
5
 
5
6
  interface WorldData {
6
7
  name: string;
@@ -43,6 +44,42 @@ export class World {
43
44
  getHighestBlockYSync(x: number, z: number): number {
44
45
  return call<number>('world.getHighestBlockY', { world: this.name, x, z });
45
46
  }
47
+ getChunkAt(x: number, z: number): Promise<Chunk> {
48
+ return post<ChunkData>('world.getChunkAt', { world: this.name, x, z }).then((d) => Chunk.from(d));
49
+ }
50
+ getChunkAtSync(x: number, z: number): Chunk {
51
+ return Chunk.from(call<ChunkData>('world.getChunkAt', { world: this.name, x, z }));
52
+ }
53
+ isChunkLoaded(x: number, z: number): Promise<boolean> {
54
+ return post<boolean>('world.isChunkLoaded', { world: this.name, x, z });
55
+ }
56
+ isChunkLoadedSync(x: number, z: number): boolean {
57
+ return call<boolean>('world.isChunkLoaded', { world: this.name, x, z });
58
+ }
59
+ loadChunk(x: number, z: number): Promise<boolean> {
60
+ return post<boolean>('world.loadChunk', { world: this.name, x, z });
61
+ }
62
+ loadChunkSync(x: number, z: number): boolean {
63
+ return call<boolean>('world.loadChunk', { world: this.name, x, z });
64
+ }
65
+ unloadChunk(x: number, z: number): Promise<boolean> {
66
+ return post<boolean>('world.unloadChunk', { world: this.name, x, z });
67
+ }
68
+ unloadChunkSync(x: number, z: number): boolean {
69
+ return call<boolean>('world.unloadChunk', { world: this.name, x, z });
70
+ }
71
+ getBlockLightLevel(x: number, y: number, z: number): Promise<number> {
72
+ return post<number>('world.getBlockLightLevel', { world: this.name, x, y, z });
73
+ }
74
+ getBlockLightLevelSync(x: number, y: number, z: number): number {
75
+ return call<number>('world.getBlockLightLevel', { world: this.name, x, y, z });
76
+ }
77
+ getSkyLightLevel(x: number, y: number, z: number): Promise<number> {
78
+ return post<number>('world.getSkyLightLevel', { world: this.name, x, y, z });
79
+ }
80
+ getSkyLightLevelSync(x: number, y: number, z: number): number {
81
+ return call<number>('world.getSkyLightLevel', { world: this.name, x, y, z });
82
+ }
46
83
  getGameRule(rule: string): Promise<string | null> {
47
84
  return post<string | null>('world.getGameRule', { world: this.name, rule });
48
85
  }
@@ -1,3 +0,0 @@
1
- declare module '__yeow-assets' {
2
- export function getPath(path: string): string;
3
- }
@@ -1,7 +0,0 @@
1
- /// <reference path="assets-path.d.ts" />
2
-
3
- import { getPath as _getPath } from '__yeow-assets';
4
-
5
- export function getAssetsPath(path: string): string {
6
- return _getPath(path);
7
- }