Skip to content
Permalink
Browse files

Clamp the volume for all sounds, rather than just notes

This restores the previous behaviour.
  • Loading branch information...
SquidDev committed Oct 12, 2018
1 parent e7c19bc commit 5694491124988e22a576e9d9c84ae14618f795ff
@@ -132,10 +132,7 @@ public String getType()
}

// If the resource location for note block notes changes, this method call will need to be updated
boolean success = playSound( context, noteName,
Math.min( volume, 3f ),
(float) Math.pow( 2.0, (pitch - 12.0) / 12.0 ), true
);
boolean success = playSound( context, noteName, volume, (float) Math.pow( 2.0, (pitch - 12.0) / 12.0 ), true );

if( success ) m_notesThisTick++;
return new Object[] { success };
@@ -151,17 +148,18 @@ private synchronized boolean playSound( ILuaContext context, String name, float
return false;
}

final World world = getWorld();
final BlockPos pos = getPos();
World world = getWorld();
BlockPos pos = getPos();

context.issueMainThreadTask( () -> {
MinecraftServer server = world.getMinecraftServer();
if( server == null ) return null;

double x = pos.getX() + 0.5, y = pos.getY() + 0.5, z = pos.getZ() + 0.5;
float adjVolume = Math.min( volume, 3.0f );
server.getPlayerList().sendToAllNearExcept(
null, x, y, z, volume > 1.0f ? 16 * volume : 16.0, world.provider.getDimension(),
new SPacketCustomSound( name, SoundCategory.RECORDS, x, y, z, volume, pitch )
null, x, y, z, adjVolume > 1.0f ? 16 * adjVolume : 16.0, world.provider.getDimension(),
new SPacketCustomSound( name, SoundCategory.RECORDS, x, y, z, adjVolume, pitch )
);
return null;
} );

0 comments on commit 5694491

Please sign in to comment.
You can’t perform that action at this time.