Sounds on shared and server
This commit is contained in:
@@ -11,6 +11,7 @@ import type {
|
||||
Id,
|
||||
ItemStack,
|
||||
ModInfo,
|
||||
PlayOptions,
|
||||
Position,
|
||||
RecipeLookup,
|
||||
Season,
|
||||
@@ -32,6 +33,7 @@ export type {
|
||||
Id,
|
||||
ItemStack,
|
||||
ModInfo,
|
||||
PlayOptions,
|
||||
Position,
|
||||
Season,
|
||||
TagApi,
|
||||
@@ -65,9 +67,19 @@ export interface ServerContext {
|
||||
ui: ServerUi;
|
||||
net: ServerNet;
|
||||
storage: ModStorage;
|
||||
// sounds from the mods' sounds.json, played on players' clients, see docs/modding/resources/sounds.md
|
||||
sounds: ServerSounds;
|
||||
log(...args: unknown[]): void;
|
||||
}
|
||||
|
||||
// one-off sounds. what lasts, like a machine's hum, is a client phase's to play, see ClientSounds in cubi/client
|
||||
export interface ServerSounds {
|
||||
// once at x y z, for every player within its range. except leaves out a player whose own client already played it,
|
||||
// like the one whose click a client phase answered with a sound. throws for a sound no mod defines
|
||||
play(sound: Id, x: number, y: number, z: number, options?: PlayOptions & { except?: Player }): void;
|
||||
exists(sound: Id): boolean;
|
||||
}
|
||||
|
||||
// components
|
||||
|
||||
export interface BlockRef {
|
||||
@@ -90,6 +102,8 @@ export interface BlockRef {
|
||||
// turns on_tick and on_second off for this block, or back on, like a machine with nothing to do. it stays off until
|
||||
// it's turned on again, saved with the world, and goes with the block
|
||||
set_ticking(ticking: boolean): void;
|
||||
// ctx.sounds.play at its middle
|
||||
play_sound(sound: Id, options?: PlayOptions): void;
|
||||
}
|
||||
|
||||
// P is the component's params from the block json
|
||||
@@ -295,6 +309,8 @@ export interface MobRef extends LivingRef {
|
||||
// removes one
|
||||
get_client_data<T>(field: string): T | undefined;
|
||||
set_client_data(field: string, value: unknown): void;
|
||||
// a sound following it, like EntityRef.play_sound
|
||||
play_sound(sound: Id, options?: PlayOptions): void;
|
||||
}
|
||||
|
||||
// commands, brigadier's way like neoforge's: see common/commands.ts and docs/modding/misc/commands.md
|
||||
@@ -570,6 +586,8 @@ export interface EntityRef {
|
||||
// changes what an item lying around is, like ItemEntity.setItem. undefined or a count of 0 removes it. throws for
|
||||
// every other kind of entity
|
||||
set_item(item: ItemStack | undefined): void;
|
||||
// a sound following it, once, for every player who sees it and is within its range
|
||||
play_sound(sound: Id, options?: PlayOptions): void;
|
||||
}
|
||||
|
||||
export interface Player {
|
||||
@@ -634,6 +652,9 @@ export interface Player {
|
||||
// every tick, then on_finish_using after ticks, or on_release_using if they let go first. -1 uses it until they let
|
||||
// go, like a bow. it slows them down like sneaking. for an on_use to call. switching away from it stops it
|
||||
start_using(ticks: number): void;
|
||||
// a sound only they hear, as it is wherever they are, like one in a menu. ctx.sounds.play for one others near
|
||||
// them hear too
|
||||
play_sound(sound: Id, options?: PlayOptions): void;
|
||||
// stops using it without on_release_using or on_finish_using, like stopUsingItem
|
||||
stop_using(): void;
|
||||
is_using(): boolean;
|
||||
|
||||
Reference in New Issue
Block a user