Skip to content

Commit

Permalink
Simplify a bit the snow air absorption
Browse files Browse the repository at this point in the history
Signed-off-by: djpadbit <[email protected]>
  • Loading branch information
djpadbit committed Oct 23, 2019
1 parent aa4b5e5 commit 7c1b392
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/main/java/com/sonicether/soundphysics/SoundPhysics.java
Original file line number Diff line number Diff line change
Expand Up @@ -618,22 +618,17 @@ private static void evaluateEnvironment(final int sourceID, final float posX, fi
final Vec3d soundPos = offsetSoundByName(posX, posY, posZ, playerPos, name, category);
final Vec3d normalToPlayer = playerPos.subtract(soundPos).normalize();

float snowFactor = 0.0f;
float airAbsorptionFactor = 1.0f;

if (mc.world.isRaining()) {
if (Config.snowAirAbsorptionFactor > 1.0f && mc.world.isRaining()) {
final Vec3d middlePos = playerPos.add(soundPos).scale(0.5);
final BlockPos playerPosBlock = new BlockPos(playerPos);
final BlockPos soundPosBlock = new BlockPos(soundPos);
final BlockPos middlePosBlock = new BlockPos(middlePos);
final int snowingPlayer = isSnowingAt(playerPosBlock,false) ? 1 : 0;
final int snowingSound = isSnowingAt(soundPosBlock,false) ? 1 : 0;
final int snowingMiddle = isSnowingAt(middlePosBlock,false) ? 1 : 0;
snowFactor = snowingPlayer * 0.25f + snowingMiddle * 0.5f + snowingSound * 0.25f;
}

float airAbsorptionFactor = 1.0f;

if (snowFactor > 0.0f) {
final float snowFactor = snowingPlayer * 0.25f + snowingMiddle * 0.5f + snowingSound * 0.25f;
airAbsorptionFactor = Math.max(Config.snowAirAbsorptionFactor*mc.world.getRainStrength(1.0f)*snowFactor,airAbsorptionFactor);
}

Expand Down

0 comments on commit 7c1b392

Please sign in to comment.