geforkt von Mirrors/Paper
2f34301581
Upstream has released updates that appears to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: 7361a62e SPIGOT-5641: Add Block.getDrops(ItemStack, Entity) 1dc91b15 Add specific notes about what is not API 2b05ef88 #484: Allow statistics to be accessed for offline players CraftBukkit Changes:f7d6ad53
SPIGOT-5603: Use LootContext#lootingModifier in CraftLootTable5838285d
SPIGOT-5657: BlockPlaceEvent not cancelling for tripwire hooksf325b9be
SPIGOT-5641: Add Block.getDrops(ItemStack, Entity)e25a2272
Fix some formatting in CraftHumanEntity498540e0
Add Merchant slot delegateb2de47d5
SPIGOT-5621: Add missing container types for opening InventoryViewaa3a2f27
#645: Allow statistics to be accessed for offline players2122c0b1
#649: CraftBell should implement Bell
93 Zeilen
6.2 KiB
Diff
93 Zeilen
6.2 KiB
Diff
From 3525cf56eab8d92724da5d7edea7a0419569fab1 Mon Sep 17 00:00:00 2001
|
|
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
|
|
index 3bd5ddba68..c86d22e7ae 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -1023,6 +1023,15 @@ public abstract class EntityHuman extends EntityLiving {
|
|
return vec3d;
|
|
}
|
|
|
|
+ // 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.sendSoundEffect(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 attack(Entity entity) {
|
|
if (entity.bA()) {
|
|
if (!entity.t(this)) {
|
|
@@ -1047,7 +1056,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
int i = b0 + EnchantmentManager.b((EntityLiving) this);
|
|
|
|
if (this.isSprinting() && flag) {
|
|
- 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
|
|
++i;
|
|
flag1 = true;
|
|
}
|
|
@@ -1122,7 +1131,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
}
|
|
}
|
|
|
|
- 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
|
|
this.ea();
|
|
}
|
|
|
|
@@ -1150,15 +1159,15 @@ public abstract class EntityHuman extends EntityLiving {
|
|
}
|
|
|
|
if (flag2) {
|
|
- 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
|
|
this.a(entity);
|
|
}
|
|
|
|
if (!flag2 && !flag3) {
|
|
if (flag) {
|
|
- 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
|
|
} else {
|
|
- 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
|
|
}
|
|
}
|
|
|
|
@@ -1210,7 +1219,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
|
|
this.applyExhaustion(world.spigotConfig.combatExhaustion); // Spigot - Change to use configurable value
|
|
} else {
|
|
- 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
|
|
if (flag4) {
|
|
entity.extinguish();
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
|
index 14c97a163c..a956dbc3d4 100644
|
|
--- a/src/main/java/net/minecraft/server/World.java
|
|
+++ b/src/main/java/net/minecraft/server/World.java
|
|
@@ -584,6 +584,11 @@ public abstract class World implements GeneratorAccess, AutoCloseable {
|
|
this.playSound(entityhuman, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, soundeffect, soundcategory, f, f1);
|
|
}
|
|
|
|
+ // Paper start - OBFHELPER
|
|
+ public final void sendSoundEffect(@Nullable EntityHuman fromEntity, double x, double y, double z, SoundEffect soundeffect, SoundCategory soundcategory, float volume, float pitch) {
|
|
+ this.playSound(fromEntity, x, y, z, soundeffect, soundcategory, volume, pitch);
|
|
+ }
|
|
+ // Paper end
|
|
public abstract void playSound(@Nullable EntityHuman entityhuman, double d0, double d1, double d2, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1);
|
|
|
|
public abstract void playSound(@Nullable EntityHuman entityhuman, Entity entity, SoundEffect soundeffect, SoundCategory soundcategory, float f, float f1);
|
|
--
|
|
2.25.1
|
|
|