Fixed background music not cancelling when moving within another bard NPC's range

This commit is contained in:
luisc committed 2024-05-14 19:17:21 -05:00
1 parent 56bb6751b1
commit f6244434f7
2 files changed
+18 -6

No files matched your search

@@ -34,7 +34,7 @@ public class MusicController {
ScriptClientSound clientSound = new ScriptClientSound(music);
clientSound.setPos((float)entity.posX, (float)entity.posY, (float)entity.posZ);
clientSound.setVolume(4.0F);
clientSound.setVolume(Math.max(1, offRange/16.0F));
clientSound.setAttenuationType(ISound.AttenuationType.LINEAR);
clientSound.setRepeat(true);
this.sound = clientSound;
@@ -86,6 +86,14 @@ public class MusicController {
return this.offRange;
}
public double getDistance() {
Entity player = Minecraft.getMinecraft().thePlayer;
if (this.entity != null && this.entity.dimension == player.dimension) {
return player.getDistanceToEntity(this.entity);
}
return Double.MAX_VALUE;
}
public void playSound(String music, float x, float y, float z) {
Minecraft.getMinecraft().theWorld.playSound(x, y, z, music, 1, 1, false);
}