2020-05-06 09:48:49 +00:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2017-10-31 02:29:53 +00:00
|
|
|
From: Brokkonaut <hannos17@gmx.de>
|
|
|
|
Date: Tue, 31 Oct 2017 03:26:18 +0100
|
|
|
|
Subject: [PATCH] Send attack SoundEffects only to players who can see the
|
|
|
|
attacker
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
2021-01-29 00:32:08 +00:00
|
|
|
index 502154234632fbf65fada993f9a1e457fe8f41cd..cff46a5d962426912a7a857d8a44348d94223428 100644
|
2017-10-31 02:29:53 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2021-01-29 00:32:08 +00:00
|
|
|
@@ -1028,7 +1028,7 @@ public abstract class EntityHuman extends EntityLiving {
|
2017-10-31 02:29:53 +00:00
|
|
|
int i = b0 + EnchantmentManager.b((EntityLiving) this);
|
|
|
|
|
|
|
|
if (this.isSprinting() && flag) {
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_KNOCKBACK, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2017-10-31 02:29:53 +00:00
|
|
|
++i;
|
|
|
|
flag1 = true;
|
|
|
|
}
|
2021-01-29 00:32:08 +00:00
|
|
|
@@ -1103,7 +1103,7 @@ public abstract class EntityHuman extends EntityLiving {
|
2017-10-31 02:29:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_SWEEP, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2020-11-03 02:22:15 +00:00
|
|
|
this.ex();
|
2017-10-31 02:29:53 +00:00
|
|
|
}
|
|
|
|
|
2021-01-29 00:32:08 +00:00
|
|
|
@@ -1131,15 +1131,15 @@ public abstract class EntityHuman extends EntityLiving {
|
2017-10-31 02:29:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (flag2) {
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_CRIT, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2017-10-31 02:29:53 +00:00
|
|
|
this.a(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!flag2 && !flag3) {
|
|
|
|
if (flag) {
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_STRONG, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2017-10-31 02:29:53 +00:00
|
|
|
} else {
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_WEAK, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2017-10-31 02:29:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-01-29 00:32:08 +00:00
|
|
|
@@ -1191,7 +1191,7 @@ public abstract class EntityHuman extends EntityLiving {
|
2017-10-31 02:29:53 +00:00
|
|
|
|
|
|
|
this.applyExhaustion(world.spigotConfig.combatExhaustion); // Spigot - Change to use configurable value
|
|
|
|
} else {
|
2019-12-11 23:43:22 +00:00
|
|
|
- this.world.playSound((EntityHuman) null, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F);
|
|
|
|
+ sendSoundEffect(this, this.locX(), this.locY(), this.locZ(), SoundEffects.ENTITY_PLAYER_ATTACK_NODAMAGE, this.getSoundCategory(), 1.0F, 1.0F); // Paper - send while respecting visibility
|
2017-10-31 02:29:53 +00:00
|
|
|
if (flag4) {
|
|
|
|
entity.extinguish();
|
|
|
|
}
|
2021-01-29 00:32:08 +00:00
|
|
|
@@ -1626,6 +1626,14 @@ public abstract class EntityHuman extends EntityLiving {
|
2020-08-25 02:22:08 +00:00
|
|
|
public int getExpToLevel() {
|
|
|
|
return this.expLevel >= 30 ? 112 + (this.expLevel - 30) * 9 : (this.expLevel >= 15 ? 37 + (this.expLevel - 15) * 5 : 7 + this.expLevel * 2);
|
|
|
|
}
|
|
|
|
+ // Paper start - send SoundEffect to everyone who can see fromEntity
|
|
|
|
+ private static void sendSoundEffect(EntityHuman fromEntity, double x, double y, double z, SoundEffect soundEffect, SoundCategory soundCategory, float volume, float pitch) {
|
|
|
|
+ fromEntity.world.playSound(fromEntity, x, y, z, soundEffect, soundCategory, volume, pitch); // This will not send the effect to the entity himself
|
|
|
|
+ if (fromEntity instanceof EntityPlayer) {
|
|
|
|
+ ((EntityPlayer) fromEntity).playerConnection.sendPacket(new PacketPlayOutNamedSoundEffect(soundEffect, soundCategory, x, y, z, volume, pitch));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
|
|
|
|
public void applyExhaustion(float f) {
|
|
|
|
if (!this.abilities.isInvulnerable) {
|