yeow-api 0.4.1 → 0.4.2
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/player.ts +22 -0
package/package.json
CHANGED
package/src/player.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { call, post } from './task.js';
|
|
|
2
2
|
import type { TaskOptions } from './task.js';
|
|
3
3
|
import { Location, LocationData } from './location.js';
|
|
4
4
|
import type { ItemStack } from './item.js';
|
|
5
|
+
import { Block } from './block.js';
|
|
5
6
|
import type { Message } from './message.js';
|
|
6
7
|
import type { Permission } from './permission.js';
|
|
7
8
|
import { Inventory } from './inventory.js';
|
|
@@ -170,6 +171,27 @@ export class Player {
|
|
|
170
171
|
}
|
|
171
172
|
teleport(loc: Location, options?: TaskOptions): Promise<void> { return post('player.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
172
173
|
teleportSync(loc: Location, options?: TaskOptions): void { call('player.teleport', { uuid: this.uuid, ...loc.toObject() }, options); }
|
|
174
|
+
/** 向玩家发送假方块变化(仅客户端视觉,不改变真实世界)。block 为 Block 对象或字符串(同 world.setBlock,字符串无状态)。 */
|
|
175
|
+
sendBlockChange(location: Location, block: Block | string, options?: TaskOptions): Promise<void> {
|
|
176
|
+
const p: Record<string, unknown> = { uuid: this.uuid, ...location.toObject() };
|
|
177
|
+
if (typeof block === 'string') {
|
|
178
|
+
p.blockType = block;
|
|
179
|
+
} else {
|
|
180
|
+
p.blockType = block.type;
|
|
181
|
+
if (block.state && Object.keys(block.state).length > 0) p.state = block.state;
|
|
182
|
+
}
|
|
183
|
+
return post('player.sendBlockChange', p, options);
|
|
184
|
+
}
|
|
185
|
+
sendBlockChangeSync(location: Location, block: Block | string, options?: TaskOptions): void {
|
|
186
|
+
const p: Record<string, unknown> = { uuid: this.uuid, ...location.toObject() };
|
|
187
|
+
if (typeof block === 'string') {
|
|
188
|
+
p.blockType = block;
|
|
189
|
+
} else {
|
|
190
|
+
p.blockType = block.type;
|
|
191
|
+
if (block.state && Object.keys(block.state).length > 0) p.state = block.state;
|
|
192
|
+
}
|
|
193
|
+
call('player.sendBlockChange', p, options);
|
|
194
|
+
}
|
|
173
195
|
sendActionBar(message: string | Message, options?: TaskOptions): Promise<void> { return post('player.sendActionBar', { uuid: this.uuid, message }, options); }
|
|
174
196
|
sendActionBarSync(message: string | Message, options?: TaskOptions): void { call('player.sendActionBar', { uuid: this.uuid, message }, options); }
|
|
175
197
|
sendResourcePack(url: string, hash?: string, prompt?: string | Message, force?: boolean, options?: TaskOptions): Promise<void> {
|