diff --git a/src/main/java/li/cil/oc2/common/bus/device/rpc/item/SoundCardItemDevice.java b/src/main/java/li/cil/oc2/common/bus/device/rpc/item/SoundCardItemDevice.java index 61846725..76830d3a 100644 --- a/src/main/java/li/cil/oc2/common/bus/device/rpc/item/SoundCardItemDevice.java +++ b/src/main/java/li/cil/oc2/common/bus/device/rpc/item/SoundCardItemDevice.java @@ -40,6 +40,16 @@ public final class SoundCardItemDevice extends AbstractItemRPCDevice { @Callback public void playSound(@Nullable @Parameter("name") final String name) { + playSound(name, 1, 1); + } + + @Callback + public void playSound(@Nullable @Parameter("name") final String name, @Parameter("volume") final float volume) { + playSound(name, volume, 1); + } + + @Callback + public void playSound(@Nullable @Parameter("name") final String name, @Parameter("volume") final float volume, @Parameter("pitch") final float pitch) { if (name == null) throw new IllegalArgumentException(); location.get().ifPresent(location -> location.tryGetLevel().ifPresent(level -> { @@ -56,7 +66,7 @@ public final class SoundCardItemDevice extends AbstractItemRPCDevice { final SoundEvent soundEvent = ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation(name)); if (soundEvent == null) throw new IllegalArgumentException("Sound not found."); - level.playSound(null, location.blockPos(), soundEvent, SoundSource.BLOCKS, 1, 1); + level.playSound(null, location.blockPos(), soundEvent, SoundSource.BLOCKS, volume, pitch); })); } diff --git a/src/main/resources/assets/oc2/doc/en_us/item/sound_card.md b/src/main/resources/assets/oc2/doc/en_us/item/sound_card.md index 0aaf7233..cf52da1d 100644 --- a/src/main/resources/assets/oc2/doc/en_us/item/sound_card.md +++ b/src/main/resources/assets/oc2/doc/en_us/item/sound_card.md @@ -12,8 +12,10 @@ This is a high level device. It must be controlled using the high level device A Device name: `sound` ### Methods -`playSound(name:string)` plays back the sound effect with the specified name. +`playSound(name:string[,volume,pitch])` plays back the sound effect with the specified name. - `name` is the name of the effect to play. +- `volume` is the volume at which to play the effect, with `1` being the normal volume. Optional, defaulting to `1`. +- `pitch` is the volume at which to play the effect, with `1` being the normal pitch. Optional, defaulting to `1`. - Throws if the specified name is invalid. `findSound(name:string):table` returns a list of available sound effects matching the given name. Note that the number of results is limited, so overly generic queries will result in truncated results.