mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Several fixes to speaker volume
- Use linear attenuation. - Fix speakers being 16 times as loud as they should be. They correctly cut off at the right distance, but didn't fade out as one might expect. - Clamp volume at 0, not 1. Fixes #892
This commit is contained in:
parent
62172c6049
commit
fa78818069
@ -61,6 +61,7 @@ public class SoundManager
|
||||
setPosition( position );
|
||||
this.volume = volume;
|
||||
this.pitch = pitch;
|
||||
attenuation = ISound.AttenuationType.LINEAR;
|
||||
}
|
||||
|
||||
void setPosition( Vector3d position )
|
||||
|
@ -176,7 +176,8 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
World world = getWorld();
|
||||
Vector3d pos = getPosition();
|
||||
|
||||
float range = MathHelper.clamp( volume, 1.0f, 3.0f ) * 16;
|
||||
float actualVolume = MathHelper.clamp( volume, 0.0f, 3.0f );
|
||||
float range = actualVolume * 16;
|
||||
|
||||
context.issueMainThreadTask( () -> {
|
||||
MinecraftServer server = world.getServer();
|
||||
@ -186,13 +187,13 @@ public abstract class SpeakerPeripheral implements IPeripheral
|
||||
{
|
||||
server.getPlayerList().broadcast(
|
||||
null, pos.x, pos.y, pos.z, range, world.dimension(),
|
||||
new SPlaySoundPacket( name, SoundCategory.RECORDS, pos, range, pitch )
|
||||
new SPlaySoundPacket( name, SoundCategory.RECORDS, pos, actualVolume, pitch )
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
NetworkHandler.sendToAllAround(
|
||||
new SpeakerPlayClientMessage( getSource(), pos, name, range, pitch ),
|
||||
new SpeakerPlayClientMessage( getSource(), pos, name, actualVolume, pitch ),
|
||||
world, pos, range
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user