diff options
author | Travis Watkins <amaranth@ubuntu.com> | 2014-07-15 18:27:27 -0500 |
---|---|---|
committer | Travis Watkins <amaranth@ubuntu.com> | 2014-07-15 21:28:10 -0500 |
commit | 594d7cb8c91943eeb0f2508a4e7b2c128d310f09 (patch) | |
tree | a0d604a31d6102c5527fd2898e641c42256f6523 /src/main/java/net/minecraft/server/EntityWither.java | |
parent | c7398b9fdf058dc99c5a4c84838245a5d3699e59 (diff) | |
download | craftbukkit-594d7cb8c91943eeb0f2508a4e7b2c128d310f09.tar craftbukkit-594d7cb8c91943eeb0f2508a4e7b2c128d310f09.tar.gz craftbukkit-594d7cb8c91943eeb0f2508a4e7b2c128d310f09.tar.lz craftbukkit-594d7cb8c91943eeb0f2508a4e7b2c128d310f09.tar.xz craftbukkit-594d7cb8c91943eeb0f2508a4e7b2c128d310f09.zip |
Don't confuse client with sound coordinates outside view distance.
Diffstat (limited to 'src/main/java/net/minecraft/server/EntityWither.java')
-rw-r--r-- | src/main/java/net/minecraft/server/EntityWither.java | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/main/java/net/minecraft/server/EntityWither.java b/src/main/java/net/minecraft/server/EntityWither.java index 4161bb1d..75b3ca3a 100644 --- a/src/main/java/net/minecraft/server/EntityWither.java +++ b/src/main/java/net/minecraft/server/EntityWither.java @@ -173,7 +173,23 @@ public class EntityWither extends EntityMonster implements IRangedEntity { // CraftBukkit end this.world.createExplosion(this, this.locX, this.locY + (double) this.getHeadHeight(), this.locZ, 7.0F, false, this.world.getGameRules().getBoolean("mobGriefing")); - this.world.b(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + // CraftBukkit start - Use relative location for far away sounds + //this.world.b(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0); + int viewDistance = ((WorldServer) this.world).getServer().getViewDistance() * 16; + for (EntityPlayer player : (List<EntityPlayer>) this.world.players) { + double deltaX = this.locX - player.locX; + double deltaZ = this.locZ - player.locZ; + double distanceSquared = deltaX * deltaX + deltaZ * deltaZ; + if (distanceSquared > viewDistance * viewDistance) { + double deltaLength = Math.sqrt(distanceSquared); + double relativeX = player.locX + (deltaX / deltaLength) * viewDistance; + double relativeZ = player.locZ + (deltaZ / deltaLength) * viewDistance; + player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1013, (int) relativeX, (int) this.locY, (int) relativeZ, 0, true)); + } else { + player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1013, (int) this.locX, (int) this.locY, (int) this.locZ, 0, true)); + } + } + // CraftBukkit end } this.s(i); |