Sound
com.jsmacrosce.jsmacros.client.api.event.impl.world.EventSound
Fires when the sound engine receives a sound instance, before it attempts playback. The reported position may be relative rather than world coordinates. Cancelling prevents the playback attempt.
js
JsMacros.on("Sound", JavaWrapper.methodToJava(function (event) {
if (event.sound === null) {
return;
}
Chat.log(`Playing ${event.sound} (volume ${event.volume}, pitch ${event.pitch})`);
if (event.volume > 2.0) {
event.cancel();
}
}))Constructors
new EventSound
Initializes this event with the supplied sound label, multipliers, and coordinates; it does not play a sound. The nullable label is stored as provided, and the coordinates are reported as supplied without conversion; they may be relative rather than world coordinates.
Parameters:
sound: nullable sound label; it is stored as provided, not looked up or validatedvolume: supplied volume multiplier, stored unchangedpitch: supplied pitch multiplier, stored unchangedx: supplied x coordinate, stored unchangedy: supplied y coordinate, stored unchangedz: supplied z coordinate, stored unchanged
Fields
pitch
Pitch reported by the sound instance;
1.0 is the unmodified value. If reading the pitch throws a NullPointerException, this is 1.0.position
sound
volume
Volume reported by the sound instance;
1.0 is the unmodified value. If reading the volume throws a NullPointerException, this is 1.0.Methods
toString
Returns a diagnostic string containing the event name and quoted sound label. The label is not escaped; a null label appears as the quoted text
"null". Volume, pitch, and position are omitted.Returns: event name followed by
:{"sound": "..."}; this is not a complete JSON representation of the event