summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTravis Watkins <amaranth@ubuntu.com>2014-07-15 18:27:27 -0500
committerTravis Watkins <amaranth@ubuntu.com>2014-07-15 21:28:10 -0500
commit594d7cb8c91943eeb0f2508a4e7b2c128d310f09 (patch)
treea0d604a31d6102c5527fd2898e641c42256f6523 /src
parentc7398b9fdf058dc99c5a4c84838245a5d3699e59 (diff)
downloadcraftbukkit-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')
-rw-r--r--src/main/java/net/minecraft/server/EntityEnderDragon.java18
-rw-r--r--src/main/java/net/minecraft/server/EntityLightning.java19
-rw-r--r--src/main/java/net/minecraft/server/EntityWither.java18
3 files changed, 52 insertions, 3 deletions
diff --git a/src/main/java/net/minecraft/server/EntityEnderDragon.java b/src/main/java/net/minecraft/server/EntityEnderDragon.java
index 51c4e6ec..78023c4b 100644
--- a/src/main/java/net/minecraft/server/EntityEnderDragon.java
+++ b/src/main/java/net/minecraft/server/EntityEnderDragon.java
@@ -544,7 +544,23 @@ public class EntityEnderDragon extends EntityInsentient implements IComplex, IMo
}
if (this.bB == 1) {
- this.world.b(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0);
+ // CraftBukkit start - Use relative location for far away sounds
+ //this.world.b(1018, (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(1018, (int) relativeX, (int) this.locY, (int) relativeZ, 0, true));
+ } else {
+ player.playerConnection.sendPacket(new PacketPlayOutWorldEvent(1018, (int) this.locX, (int) this.locY, (int) this.locZ, 0, true));
+ }
+ }
+ // CraftBukkit end
}
}
diff --git a/src/main/java/net/minecraft/server/EntityLightning.java b/src/main/java/net/minecraft/server/EntityLightning.java
index 2fd88c0f..66402a05 100644
--- a/src/main/java/net/minecraft/server/EntityLightning.java
+++ b/src/main/java/net/minecraft/server/EntityLightning.java
@@ -63,7 +63,24 @@ public class EntityLightning extends EntityWeather {
public void h() {
super.h();
if (this.lifeTicks == 2) {
- this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ // CraftBukkit start - Use relative location for far away sounds
+ //this.world.makeSound(this.locX, this.locY, this.locZ, "ambient.weather.thunder", 10000.0F, 0.8F + this.random.nextFloat() * 0.2F);
+ float pitch = 0.8F + this.random.nextFloat() * 0.2F;
+ 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 PacketPlayOutNamedSoundEffect("ambient.weather.thunder", relativeX, this.locY, relativeZ, 10000.0F, pitch));
+ } else {
+ player.playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect("ambient.weather.thunder", this.locX, this.locY, this.locZ, 10000.0F, pitch));
+ }
+ }
+ // CraftBukkit end
this.world.makeSound(this.locX, this.locY, this.locZ, "random.explode", 2.0F, 0.5F + this.random.nextFloat() * 0.2F);
}
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);