aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0289-Improve-death-events.patch
blob: 0df0db2e0bf47ed52b78701e6b4641416121a3f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Phoenix616 <mail@moep.tv>
Date: Tue, 21 Aug 2018 01:39:35 +0100
Subject: [PATCH] Improve death events

This adds the ability to cancel the death events and to modify the sound
an entity makes when dying. (In cases were no sound should it will be
called with shouldPlaySound set to false allowing unsilencing of silent
entities)

It makes handling of entity deaths a lot nicer as you no longer need
to listen on the damage event and calculate if the entity dies yourself
to cancel the death which has the benefit of also receiving the dropped
items and experience which is otherwise only properly possible by using
internal code.

diff --git a/src/main/java/net/minecraft/server/CombatTracker.java b/src/main/java/net/minecraft/server/CombatTracker.java
index 6daa400d277bdaa441bf5719a273eacbe64feff9..38fe29f8a290550d1e5fa5451aadaf0f28cc4034 100644
--- a/src/main/java/net/minecraft/server/CombatTracker.java
+++ b/src/main/java/net/minecraft/server/CombatTracker.java
@@ -175,6 +175,7 @@ public class CombatTracker {
         this.h = null;
     }
 
+    public void reset() { this.g(); } // Paper - OBFHELPER
     public void g() {
         int i = this.f ? 300 : 100;
 
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
index 6e87ff52df30f4de8cfb11d1dbfb71211d656831..0f74ec89b3e85c918c95f9d8fef6d68403ed1107 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1504,6 +1504,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
         return false;
     }
 
+    public void runKillTrigger(Entity entity, int kills, DamageSource damageSource) { this.a(entity, kills, damageSource); } // Paper - OBFHELPER
     public void a(Entity entity, int i, DamageSource damagesource) {
         if (entity instanceof EntityPlayer) {
             CriterionTriggers.c.a((EntityPlayer) entity, this, damagesource);
@@ -2419,6 +2420,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
         this.fallDistance = 0.0F;
     }
 
+    public void onKill(EntityLiving entityLiving) { this.b(entityLiving); } // Paper - OBFHELPER
     public void b(EntityLiving entityliving) {}
 
     protected void k(double d0, double d1, double d2) {
diff --git a/src/main/java/net/minecraft/server/EntityArmorStand.java b/src/main/java/net/minecraft/server/EntityArmorStand.java
index 42b9a339e9c35db596ec78881c32c801c2d739f4..8ad131e4fc20efc61b938a5f6ab64379da23bf0d 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -701,7 +701,8 @@ public class EntityArmorStand extends EntityLiving {
 
     @Override
     public void killEntity() {
-        org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event
+        org.bukkit.event.entity.EntityDeathEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityDeathEvent(this, drops); // CraftBukkit - call event // Paper - make cancellable
+        if (event.isCancelled()) return; // Paper - make cancellable
         this.die();
     }
 
diff --git a/src/main/java/net/minecraft/server/EntityFox.java b/src/main/java/net/minecraft/server/EntityFox.java
index 2be6c7bde9597d6d6d0c9ad63665b9aa74c74964..82a32d5dbf162b8c67c701d0c9647ddca103ddef 100644
--- a/src/main/java/net/minecraft/server/EntityFox.java
+++ b/src/main/java/net/minecraft/server/EntityFox.java
@@ -571,15 +571,25 @@ public class EntityFox extends EntityAnimal {
     }
 
     @Override
-    protected void d(DamageSource damagesource) {
-        ItemStack itemstack = this.getEquipment(EnumItemSlot.MAINHAND);
+    protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper
+        ItemStack itemstack = this.getEquipment(EnumItemSlot.MAINHAND).cloneItemStack(); // Paper
+
+        // Paper start - Cancellable death event
+        org.bukkit.event.entity.EntityDeathEvent deathEvent = super.d(damagesource);
+
+        // Below is code to drop
+
+        if (deathEvent == null || deathEvent.isCancelled()) {
+            return deathEvent;
+        }
+        // Paper end
 
         if (!itemstack.isEmpty()) {
             this.a(itemstack);
             this.setSlot(EnumItemSlot.MAINHAND, ItemStack.a);
         }
 
-        super.d(damagesource);
+        return deathEvent; // Paper
     }
 
     public static boolean a(EntityFox entityfox, EntityLiving entityliving) {
diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
index 80717ad9ac3d45fb2d25fac4fa1b61446aebd453..53aac5bccd2b1a36941a6744bbeece6a2f724cda 100644
--- a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
+++ b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
@@ -55,11 +55,19 @@ public abstract class EntityHorseChestedAbstract extends EntityHorseAbstract {
                 this.a((IMaterial) Blocks.CHEST);
             }
 
-            this.setCarryingChest(false);
+            //this.setCarryingChest(false); // Paper - moved to post death logic
         }
 
     }
 
+    // Paper start
+    protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
+        if (this.isCarryingChest() && (event == null || !event.isCancelled())) {
+            this.setCarryingChest(false);
+        }
+    }
+    // Paper end
+
     @Override
     public void b(NBTTagCompound nbttagcompound) {
         super.b(nbttagcompound);
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
index 93625dea9ca6a13f311dd5ecc5c0d09060c418c8..3d5668271954ede03220354985851603669a61d4 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -89,7 +89,7 @@ public abstract class EntityLiving extends Entity {
     protected float aT;
     protected float aU;
     protected float aV;
-    protected int aW;
+    protected int aW; protected int getKillCount() { return this.aW; } // Paper - OBFHELPER
     public float lastDamage;
     protected boolean jumping;
     public float aZ;
@@ -131,6 +131,7 @@ public abstract class EntityLiving extends Entity {
     public boolean collides = true;
     public boolean canPickUpLoot;
     public org.bukkit.craftbukkit.entity.CraftLivingEntity getBukkitLivingEntity() { return (org.bukkit.craftbukkit.entity.CraftLivingEntity) super.getBukkitEntity(); } // Paper
+    public boolean silentDeath = false; // Paper - mark entity as dying silently for cancellable death event
 
     @Override
     public float getBukkitYaw() {
@@ -1139,13 +1140,17 @@ public abstract class EntityLiving extends Entity {
 
             if (this.getHealth() <= 0.0F) {
                 if (!this.f(damagesource)) {
-                    SoundEffect soundeffect = this.getSoundDeath();
+                    // Paper start - moved into CraftEventFactory event caller for cancellable death event
+                    //SoundEffect soundeffect = this.getSoundDeath();
 
-                    if (flag1 && soundeffect != null) {
-                        this.a(soundeffect, this.getSoundVolume(), this.dn());
-                    }
+//                    if (flag1 && soundeffect != null) {
+//                        this.a(soundeffect, this.getSoundVolume(), this.dn());
+//                    }
+                    this.silentDeath = !flag1; // mark entity as dying silently
+                    // Paper end
 
                     this.die(damagesource);
+                    this.silentDeath = false; // Paper - cancellable death event - reset to default
                 }
             } else if (flag1) {
                 this.c(damagesource);
@@ -1283,6 +1288,7 @@ public abstract class EntityLiving extends Entity {
             Entity entity = damagesource.getEntity();
             EntityLiving entityliving = this.getKillingEntity();
 
+            /* // Paper - move down to make death event cancellable
             if (this.aW >= 0 && entityliving != null) {
                 entityliving.a(this, this.aW, damagesource);
             }
@@ -1294,16 +1300,36 @@ public abstract class EntityLiving extends Entity {
             if (this.isSleeping()) {
                 this.entityWakeup();
             }
+            */ // Paper
 
             this.killed = true;
-            this.getCombatTracker().g();
+            //this.getCombatTracker().g();
             if (!this.world.isClientSide) {
-                this.d(damagesource);
+                org.bukkit.event.entity.EntityDeathEvent deathEvent = this.d(damagesource);
+                if (deathEvent == null || !deathEvent.isCancelled()) {
+                    if (this.getKillCount() >= 0 && entityliving != null) {
+                        entityliving.runKillTrigger(this, this.getKillCount(), damagesource);
+                    }
+                    if (entity != null) {
+                        entity.onKill(this);
+                    }
+                    if (this.isSleeping()) {
+                        this.entityWakeup();
+                    }
+                    this.getCombatTracker().reset();
+                } else {
+                    this.killed = false;
+                    this.setHealth((float) deathEvent.getReviveHealth());
+                }
+                // Paper end
+
                 this.f(entityliving);
             }
 
+            if (this.killed) { // Paper
             this.world.broadcastEntityEffect(this, (byte) 3);
             this.setPose(EntityPose.DYING);
+            } // Paper
         }
     }
 
@@ -1311,7 +1337,7 @@ public abstract class EntityLiving extends Entity {
         if (!this.world.isClientSide) {
             boolean flag = false;
 
-            if (entityliving instanceof EntityWither) {
+            if (this.killed && entityliving instanceof EntityWither) { // Paper
                 if (this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
                     BlockPosition blockposition = new BlockPosition(this);
                     IBlockData iblockdata = Blocks.WITHER_ROSE.getBlockData();
@@ -1332,7 +1358,8 @@ public abstract class EntityLiving extends Entity {
         }
     }
 
-    protected void d(DamageSource damagesource) {
+    protected org.bukkit.event.entity.EntityDeathEvent processDeath(DamageSource damagesource) { return d(damagesource); } // Paper - OBFHELPER
+    protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper
         Entity entity = damagesource.getEntity();
         int i;
 
@@ -1345,22 +1372,26 @@ public abstract class EntityLiving extends Entity {
         boolean flag = this.lastDamageByPlayerTime > 0;
 
         this.dropInventory(); // CraftBukkit - from below
+        org.bukkit.event.entity.EntityDeathEvent deathEvent; // Paper
         if (this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
             this.a(damagesource, flag);
             this.dropDeathLoot(damagesource, i, flag);
             // CraftBukkit start - Call death event
-            CraftEventFactory.callEntityDeathEvent(this, this.drops);
-            this.drops = new ArrayList<org.bukkit.inventory.ItemStack>();
+            deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops); // Paper
         } else {
-            CraftEventFactory.callEntityDeathEvent(this);
+            deathEvent = CraftEventFactory.callEntityDeathEvent(this); // Paper
             // CraftBukkit end
         }
+        this.postDeathDropItems(deathEvent); // Paper
+        this.drops = new ArrayList<>(); // Paper
 
         // this.dropInventory();// CraftBukkit - moved up
         this.dropExperience();
+        return deathEvent; // Paper
     }
 
     protected void dropInventory() {}
+    protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {} // Paper - method for post death logic that cannot be ran before the event is potentially cancelled
 
     // CraftBukkit start
     public int getExpReward() {
@@ -1439,6 +1470,7 @@ public abstract class EntityLiving extends Entity {
         return SoundEffects.ENTITY_GENERIC_HURT;
     }
 
+    public final SoundEffect getDeathSoundEffect() { return this.getSoundDeath(); } // Paper - OBFHELPER
     @Nullable
     protected SoundEffect getSoundDeath() {
         return SoundEffects.ENTITY_GENERIC_DEATH;
@@ -1924,10 +1956,12 @@ public abstract class EntityLiving extends Entity {
 
     }
 
+    public final float getDeathSoundVolume() { return this.getSoundVolume(); } // Paper - OBFHELPER
     protected float getSoundVolume() {
         return 1.0F;
     }
 
+    public float getSoundPitch() { return dn();} // Paper - OBFHELPER
     protected float dn() {
         return this.isBaby() ? (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.5F : (this.random.nextFloat() - this.random.nextFloat()) * 0.2F + 1.0F;
     }
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index f35d23340665ab323732915efc0c0ad7fe4d964d..f43584f0e31a1c3d0e9b4356b7021cd79226d8b5 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -76,6 +76,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
     public int ping;
     public boolean viewingCredits;
     private int containerUpdateDelay; // Paper
+    // Paper start - cancellable death event
+    public boolean queueHealthUpdatePacket = false;
+    public net.minecraft.server.PacketPlayOutUpdateHealth queuedHealthUpdatePacket;
+    // Paper end
 
     // CraftBukkit start
     public String displayName;
@@ -539,6 +543,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
 
         String deathmessage = defaultMessage.getString();
         org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage, keepInventory);
+        // Paper start - cancellable death event
+        if (event.isCancelled()) {
+            // make compatible with plugins that might have already set the health in an event listener
+            if (this.getHealth() <= 0) {
+                this.setHealth((float) event.getReviveHealth());
+            }
+            return;
+        }
+        // Paper end
 
         // SPIGOT-943 - only call if they have an inventory open
         if (this.activeContainer != this.defaultContainer) {
@@ -677,8 +690,17 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
                         }
                     }
                 }
-
-                return super.damageEntity(damagesource, f);
+                // Paper start - cancellable death events
+                //return super.damageEntity(damagesource, f);
+                this.queueHealthUpdatePacket = true;
+                boolean damaged = super.damageEntity(damagesource, f);
+                this.queueHealthUpdatePacket = false;
+                if (this.queuedHealthUpdatePacket != null) {
+                    this.playerConnection.sendPacket(this.queuedHealthUpdatePacket);
+                    this.queuedHealthUpdatePacket = null;
+                }
+                return damaged;
+                // Paper end
             }
         }
     }
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftSound.java b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
index 90fdf89c811620d3c26486cd55c8cdb14ce9654c..b761a41dcd899b6556f07d3b835ce7e56da3cfbb 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
@@ -821,6 +821,22 @@ public enum CraftSound {
     WEATHER_RAIN_ABOVE("weather.rain.above");
     private final String minecraftKey;
 
+    // Paper start - cancellable death event
+    public static CraftSound getBySoundEffect(final SoundEffect effect) {
+        MinecraftKey key = IRegistry.SOUND_EVENT.getKey(effect);
+        Preconditions.checkArgument(key != null, "Key for sound effect %s not found?", effect.toString());
+
+        return valueOf(key.getKey().replace('.', '_').toUpperCase(java.util.Locale.ENGLISH));
+    }
+
+    public static Sound getSoundByEffect(final SoundEffect effect) {
+        return Sound.valueOf(getBySoundEffect(effect).name());
+    }
+
+    public static SoundEffect getSoundEffect(final Sound sound) {
+        return getSoundEffect(getSound(sound));
+    }
+    // Paper end
     CraftSound(String minecraftKey) {
         this.minecraftKey = minecraftKey;
     }
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index fefe3b67ae62daedeb214d53d0c1f9d806356792..5445554b18c22b85cf9b3427c22d693a24bc596b 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1697,7 +1697,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
     }
 
     public void sendHealthUpdate() {
-        getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
+        // Paper start - cancellable death event
+        //getHandle().playerConnection.sendPacket(new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel()));
+        PacketPlayOutUpdateHealth packet = new PacketPlayOutUpdateHealth(getScaledHealth(), getHandle().getFoodData().getFoodLevel(), getHandle().getFoodData().getSaturationLevel());
+        if (this.getHandle().queueHealthUpdatePacket) {
+            this.getHandle().queuedHealthUpdatePacket = packet;
+        } else {
+            this.getHandle().playerConnection.sendPacket(packet);
+        }
+        // Paper end
     }
 
     public void injectScaledMaxHealth(Collection<AttributeInstance> collection, boolean force) {
diff --git a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
index 4329780e9de3337fd8fcca78b1ed8804e4687552..91cfc6966e19a8d3d3b2cafdb0464162c9a94de5 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -757,9 +757,16 @@ public class CraftEventFactory {
     public static EntityDeathEvent callEntityDeathEvent(EntityLiving victim, List<org.bukkit.inventory.ItemStack> drops) {
         CraftLivingEntity entity = (CraftLivingEntity) victim.getBukkitEntity();
         EntityDeathEvent event = new EntityDeathEvent(entity, drops, victim.getExpReward());
+        populateFields(victim, event); // Paper - make cancellable
         CraftWorld world = (CraftWorld) entity.getWorld();
         Bukkit.getServer().getPluginManager().callEvent(event);
 
+        // Paper start - make cancellable
+        if (event.isCancelled()) {
+            return event;
+        }
+        playDeathSound(victim, event);
+        // Paper end
         victim.expToDrop = event.getDroppedExp();
 
         for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
@@ -775,8 +782,15 @@ public class CraftEventFactory {
         CraftPlayer entity = victim.getBukkitEntity();
         PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage);
         event.setKeepInventory(keepInventory);
+        populateFields(victim, event); // Paper - make cancellable
         org.bukkit.World world = entity.getWorld();
         Bukkit.getServer().getPluginManager().callEvent(event);
+        // Paper start - make cancellable
+        if (event.isCancelled()) {
+            return event;
+        }
+        playDeathSound(victim, event);
+        // Paper end
 
         victim.keepLevel = event.getKeepLevel();
         victim.newLevel = event.getNewLevel();
@@ -793,6 +807,31 @@ public class CraftEventFactory {
         return event;
     }
 
+    // Paper start - helper methods for making death event cancellable
+    // Add information to death event
+    private static void populateFields(EntityLiving victim, EntityDeathEvent event) {
+        event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue());
+        event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent());
+        net.minecraft.server.SoundEffect soundEffect = victim.getDeathSoundEffect();
+        event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getSoundByEffect(soundEffect) : null);
+        event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundCategory().name()));
+        event.setDeathSoundVolume(victim.getDeathSoundVolume());
+        event.setDeathSoundPitch(victim.getSoundPitch());
+    }
+
+    // Play death sound manually
+    private static void playDeathSound(EntityLiving victim, EntityDeathEvent event) {
+        if (event.shouldPlayDeathSound() && event.getDeathSound() != null && event.getDeathSoundCategory() != null) {
+            EntityHuman source = victim instanceof EntityHuman ? (EntityHuman) victim : null;
+            double x = event.getEntity().getLocation().getX();
+            double y = event.getEntity().getLocation().getY();
+            double z = event.getEntity().getLocation().getZ();
+            net.minecraft.server.SoundEffect soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound());
+            net.minecraft.server.SoundCategory soundCategory = net.minecraft.server.SoundCategory.valueOf(event.getDeathSoundCategory().name());
+            victim.world.sendSoundEffect(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch());
+        }
+    }
+    // Paper end
     /**
      * Server methods
      */