Paper/patches/server/0255-Improve-death-events.patch

405 lines
21 KiB
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
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.
2021-06-13 06:03:02 +02:00
TODO 1.17: this needs to be checked (actually get off your lazy ass and cancel the events) for the following entities,
maybe more (please check patch overrides for drops for more):
- players, armor stands, foxes, chested donkeys/llamas
== AT ==
public net.minecraft.world.entity.LivingEntity getDeathSound()Lnet/minecraft/sounds/SoundEvent;
public net.minecraft.world.entity.LivingEntity getSoundVolume()F
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index cd392d316f35ac488c49ad8c34c0273bbccc6a1c..db02d7938c79995b8acc4184c1be2fe39cbf479c 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2022-12-07 20:22:28 +01:00
@@ -235,6 +235,10 @@ public class ServerPlayer extends Player {
2021-06-11 14:02:28 +02:00
public int latency;
public boolean wonGame;
private int containerUpdateDelay; // Paper
+ // Paper start - cancellable death event
+ public boolean queueHealthUpdatePacket = false;
+ public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
+ // Paper end
// CraftBukkit start
public String displayName;
2022-12-07 20:22:28 +01:00
@@ -823,6 +827,15 @@ public class ServerPlayer extends Player {
String deathmessage = defaultMessage.getString();
this.keepLevel = keepInventory; // SPIGOT-2222: pre-set keepLevel
2021-06-11 14:02:28 +02:00
org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, PaperAdventure.asAdventure(defaultMessage), defaultMessage.getString(), keepInventory); // Paper - Adventure
+ // 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.containerMenu != this.inventoryMenu) {
2022-12-07 20:22:28 +01:00
@@ -968,8 +981,17 @@ public class ServerPlayer extends Player {
2021-06-11 14:02:28 +02:00
}
}
}
-
- return super.hurt(source, amount);
+ // Paper start - cancellable death events
2021-06-13 06:03:02 +02:00
+ //return super.hurt(source, amount);
2021-06-11 14:02:28 +02:00
+ this.queueHealthUpdatePacket = true;
+ boolean damaged = super.hurt(source, amount);
+ this.queueHealthUpdatePacket = false;
+ if (this.queuedHealthUpdatePacket != null) {
+ this.connection.send(this.queuedHealthUpdatePacket);
+ this.queuedHealthUpdatePacket = null;
+ }
+ return damaged;
+ // Paper end
}
}
}
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2022-12-16 18:15:21 +01:00
index dc78b04128c5eb2375a049948133aa05fff2c022..d9b2f2e230abd3ee5b7d77c76472a86cb38255a4 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
2022-12-07 20:22:28 +01:00
@@ -263,6 +263,7 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
public Set<UUID> collidableExemptions = new HashSet<>();
2021-06-13 06:03:02 +02:00
public boolean bukkitPickUpLoot;
2021-06-11 14:02:28 +02:00
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() {
2022-12-07 20:22:28 +01:00
@@ -1466,13 +1467,12 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
if (knockbackCancelled) this.level.broadcastEntityEvent(this, (byte) 2); // Paper - Disable explosion knockback
if (this.isDeadOrDying()) {
if (!this.checkTotemDeathProtection(source)) {
- SoundEvent soundeffect = this.getDeathSound();
2021-06-13 06:03:02 +02:00
-
2021-06-11 14:02:28 +02:00
- if (flag1 && soundeffect != null) {
- this.playSound(soundeffect, this.getSoundVolume(), this.getVoicePitch());
- }
2021-06-13 06:03:02 +02:00
+ // Paper start - moved into CraftEventFactory event caller for cancellable death event
2021-06-11 14:02:28 +02:00
+ this.silentDeath = !flag1; // mark entity as dying silently
+ // Paper end
this.die(source);
+ this.silentDeath = false; // Paper - cancellable death event - reset to default
}
} else if (flag1) {
this.playHurtSound(source);
2022-12-07 20:22:28 +01:00
@@ -1624,7 +1624,7 @@ public abstract class LivingEntity extends Entity {
2021-06-13 06:03:02 +02:00
if (!this.isRemoved() && !this.dead) {
2022-06-08 02:15:06 +02:00
Entity entity = damageSource.getEntity();
2021-06-11 14:02:28 +02:00
LivingEntity entityliving = this.getKillCredit();
2021-06-13 06:03:02 +02:00
-
+ /* // Paper - move down to make death event cancellable - this is the awardKillScore below
2021-06-13 06:03:02 +02:00
if (this.deathScore >= 0 && entityliving != null) {
2022-06-08 02:15:06 +02:00
entityliving.awardKillScore(this, this.deathScore, damageSource);
2021-06-11 14:02:28 +02:00
}
2022-12-07 20:22:28 +01:00
@@ -1636,20 +1636,53 @@ public abstract class LivingEntity extends Entity {
2021-07-07 08:52:40 +02:00
if (!this.level.isClientSide && this.hasCustomName()) {
if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot
2021-07-07 08:52:40 +02:00
}
+ */ // Paper - move down to make death event cancellable - this is the awardKillScore below
2021-07-07 08:52:40 +02:00
2021-06-11 14:02:28 +02:00
this.dead = true;
- this.getCombatTracker().recheckStatus();
2021-06-13 06:03:02 +02:00
+ // Paper - moved into if below
2021-06-11 14:02:28 +02:00
if (this.level instanceof ServerLevel) {
2022-06-08 02:15:06 +02:00
- if (entity == null || entity.wasKilled((ServerLevel) this.level, this)) {
+ // Paper - move below into if for onKill
+
2021-06-11 14:02:28 +02:00
+ // Paper start
2022-06-08 02:15:06 +02:00
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.dropAllDeathLoot(damageSource);
2021-06-11 14:02:28 +02:00
+ if (deathEvent == null || !deathEvent.isCancelled()) {
2021-06-13 06:03:02 +02:00
+ if (this.deathScore >= 0 && entityliving != null) {
2022-06-08 02:15:06 +02:00
+ entityliving.awardKillScore(this, this.deathScore, damageSource);
2021-06-11 14:02:28 +02:00
+ }
+ // Paper start - clear equipment if event is not cancelled
+ if (this instanceof Mob) {
+ for (EquipmentSlot slot : this.clearedEquipmentSlots) {
+ this.setItemSlot(slot, ItemStack.EMPTY);
+ }
+ this.clearedEquipmentSlots.clear();
+ }
+ // Paper end
2021-06-13 06:03:02 +02:00
+
2021-06-11 14:02:28 +02:00
+ if (this.isSleeping()) {
+ this.stopSleeping();
+ }
2021-06-13 06:03:02 +02:00
+
+ if (!this.level.isClientSide && this.hasCustomName()) {
+ if (org.spigotmc.SpigotConfig.logNamedDeaths) LivingEntity.LOGGER.info("Named entity {} died: {}", this, this.getCombatTracker().getDeathMessage().getString()); // Spigot
+ }
+
2021-06-13 06:03:02 +02:00
+ this.getCombatTracker().recheckStatus();
2021-06-11 14:02:28 +02:00
+ if (entity != null) {
2022-06-08 02:15:06 +02:00
+ entity.wasKilled((ServerLevel) this.level, this);
2021-06-11 14:02:28 +02:00
+ }
2022-06-08 02:15:06 +02:00
this.gameEvent(GameEvent.ENTITY_DIE);
- this.dropAllDeathLoot(damageSource);
- this.createWitherRose(entityliving);
2021-06-11 14:02:28 +02:00
+ } else {
+ this.dead = false;
+ this.setHealth((float) deathEvent.getReviveHealth());
2022-06-08 02:15:06 +02:00
}
-
- this.level.broadcastEntityEvent(this, (byte) 3);
2021-06-11 14:02:28 +02:00
+ // Paper end
2022-06-08 02:15:06 +02:00
+ this.createWitherRose(entityliving);
2021-06-11 14:02:28 +02:00
}
+ if (this.dead) { // Paper
2022-06-08 02:15:06 +02:00
+ this.level.broadcastEntityEvent(this, (byte) 3);
2021-06-11 14:02:28 +02:00
this.setPose(Pose.DYING);
+ } // Paper
}
}
2022-12-07 20:22:28 +01:00
@@ -1657,7 +1690,7 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
if (!this.level.isClientSide) {
boolean flag = false;
- if (adversary instanceof WitherBoss) {
+ if (this.dead && adversary instanceof WitherBoss) { // Paper
if (this.level.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
BlockPos blockposition = this.blockPosition();
BlockState iblockdata = Blocks.WITHER_ROSE.defaultBlockState();
2022-12-07 20:22:28 +01:00
@@ -1686,7 +1719,11 @@ public abstract class LivingEntity extends Entity {
2021-06-11 14:02:28 +02:00
}
}
- protected void dropAllDeathLoot(DamageSource source) {
+ // Paper start
+ protected boolean clearEquipmentSlots = true;
+ protected Set<EquipmentSlot> clearedEquipmentSlots = new java.util.HashSet<>();
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
+ // Paper end
2021-06-13 06:03:02 +02:00
Entity entity = source.getEntity();
2021-06-11 14:02:28 +02:00
int i;
2022-12-07 20:22:28 +01:00
@@ -1701,18 +1738,27 @@ public abstract class LivingEntity extends Entity {
this.dropEquipment(); // CraftBukkit - from below
if (this.shouldDropLoot() && this.level.getGameRules().getBoolean(GameRules.RULE_DOMOBLOOT)) {
this.dropFromLootTable(source, flag);
+ // Paper start
+ final boolean prev = this.clearEquipmentSlots;
+ this.clearEquipmentSlots = false;
+ this.clearedEquipmentSlots.clear();
+ // Paper end
2021-06-13 06:03:02 +02:00
this.dropCustomDeathLoot(source, i, flag);
+ this.clearEquipmentSlots = prev; // Paper
2021-06-11 14:02:28 +02:00
}
// CraftBukkit start - Call death event
- CraftEventFactory.callEntityDeathEvent(this, this.drops);
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = CraftEventFactory.callEntityDeathEvent(this, this.drops); // Paper
+ this.postDeathDropItems(deathEvent); // Paper
this.drops = new ArrayList<>();
// CraftBukkit end
// this.dropInventory();// CraftBukkit - moved up
this.dropExperience();
+ return deathEvent; // Paper
}
protected void dropEquipment() {}
+ 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() {
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
2022-12-07 20:22:28 +01:00
index 6f728231a7b326e605d6ddb8e4cd6f0f0aec820b..f61a4409ebb5ed89e5a5cfe0488498a52faa2346 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
2022-12-07 20:22:28 +01:00
@@ -1036,7 +1036,13 @@ public abstract class Mob extends LivingEntity {
}
this.spawnAtLocation(itemstack);
+ if (this.clearEquipmentSlots) { // Paper
this.setItemSlot(enumitemslot, ItemStack.EMPTY);
+ // Paper start
+ } else {
+ this.clearedEquipmentSlots.add(enumitemslot);
+ }
+ // Paper end
}
}
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/animal/Fox.java b/src/main/java/net/minecraft/world/entity/animal/Fox.java
2022-12-07 20:22:28 +01:00
index dd124ccbdc7efe0e41b3a04abddcb328cac44948..f4cfefd72704b3423392ffeb57e78c5d6410ff6f 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/animal/Fox.java
+++ b/src/main/java/net/minecraft/world/entity/animal/Fox.java
2022-12-07 20:22:28 +01:00
@@ -705,15 +705,25 @@ public class Fox extends Animal implements VariantHolder<Fox.Type> {
2021-06-11 14:02:28 +02:00
}
@Override
- protected void dropAllDeathLoot(DamageSource source) {
- ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND);
2021-06-13 06:03:02 +02:00
+ // Paper start - Cancellable death event
+ protected org.bukkit.event.entity.EntityDeathEvent dropAllDeathLoot(DamageSource source) {
+ ItemStack itemstack = this.getItemBySlot(EquipmentSlot.MAINHAND).copy(); // Paper - modified by supercall
2021-06-11 14:02:28 +02:00
+
2021-06-13 06:03:02 +02:00
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.dropAllDeathLoot(source);
2021-06-11 14:02:28 +02:00
+
+ // Below is code to drop
+
+ if (deathEvent == null || deathEvent.isCancelled()) {
+ return deathEvent;
+ }
+ // Paper end
if (!itemstack.isEmpty()) {
this.spawnAtLocation(itemstack);
this.setItemSlot(EquipmentSlot.MAINHAND, ItemStack.EMPTY);
}
- super.dropAllDeathLoot(source);
+ return deathEvent; // Paper
}
public static boolean isPathClear(Fox fox, LivingEntity chasedEntity) {
diff --git a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
2022-12-07 20:22:28 +01:00
index 65dd844b9b38730a819158e1023c4abd829b52bb..170411b42aeef69c796d1409b59c3eb69f78c710 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
+++ b/src/main/java/net/minecraft/world/entity/animal/horse/AbstractChestedHorse.java
2022-06-08 02:15:06 +02:00
@@ -69,11 +69,19 @@ public abstract class AbstractChestedHorse extends AbstractHorse {
2021-06-13 06:03:02 +02:00
this.spawnAtLocation(Blocks.CHEST);
2021-06-11 14:02:28 +02:00
}
- this.setChest(false);
+ //this.setCarryingChest(false); // Paper - moved to post death logic
}
}
+ // Paper start
+ protected void postDeathDropItems(org.bukkit.event.entity.EntityDeathEvent event) {
+ if (this.hasChest() && (event == null || !event.isCancelled())) {
+ this.setChest(false);
+ }
+ }
+ // Paper end
+
@Override
2021-06-13 06:03:02 +02:00
public void addAdditionalSaveData(CompoundTag nbt) {
super.addAdditionalSaveData(nbt);
2021-06-11 14:02:28 +02:00
diff --git a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
index f70f75867a8f03d42f240a0d007d2221269f2fdb..e463ae13ce6f65675c2b6d553ecf91db5a047dbc 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
+++ b/src/main/java/net/minecraft/world/entity/decoration/ArmorStand.java
@@ -753,7 +753,8 @@ public class ArmorStand extends LivingEntity {
2021-06-11 14:02:28 +02:00
@Override
public void kill() {
- 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
2021-06-13 06:03:02 +02:00
this.remove(Entity.RemovalReason.KILLED);
2022-06-08 02:15:06 +02:00
this.gameEvent(GameEvent.ENTITY_DIE);
2021-06-11 14:02:28 +02:00
}
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2022-12-16 18:15:21 +01:00
index 7465d8de698d9eed71c96019fc55d6efdd13269c..03f9d58fa5158b50e12edd6a91ff263e08555870 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
2022-12-16 18:15:21 +01:00
@@ -2156,7 +2156,14 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2021-06-11 14:02:28 +02:00
}
public void sendHealthUpdate() {
2021-06-13 06:03:02 +02:00
- this.getHandle().connection.send(new ClientboundSetHealthPacket(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel()));
2021-06-11 14:02:28 +02:00
+ // Paper start - cancellable death event
2021-06-13 06:03:02 +02:00
+ ClientboundSetHealthPacket packet = new ClientboundSetHealthPacket(this.getScaledHealth(), this.getHandle().getFoodData().getFoodLevel(), this.getHandle().getFoodData().getSaturationLevel());
2021-06-11 14:02:28 +02:00
+ if (this.getHandle().queueHealthUpdatePacket) {
+ this.getHandle().queuedHealthUpdatePacket = packet;
+ } else {
+ this.getHandle().connection.send(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 b653121dc16ce4ab3f32456e0c8690e022aa263c..2d55260f4c753bfdd9f7fca69f1a9a1df0d28d1c 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -807,9 +807,16 @@ public class CraftEventFactory {
2021-06-11 14:02:28 +02:00
public static EntityDeathEvent callEntityDeathEvent(net.minecraft.world.entity.LivingEntity 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()) {
@@ -826,8 +833,15 @@ public class CraftEventFactory {
2021-06-11 14:02:28 +02:00
PlayerDeathEvent event = new PlayerDeathEvent(entity, drops, victim.getExpReward(), 0, deathMessage, stringDeathMessage); // Paper - Adventure
event.setKeepInventory(keepInventory);
event.setKeepLevel(victim.keepLevel); // SPIGOT-2222: pre-set keepLevel
2021-06-11 14:02:28 +02:00
+ 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();
@@ -844,6 +858,31 @@ public class CraftEventFactory {
2021-06-11 14:02:28 +02:00
return event;
}
+ // Paper start - helper methods for making death event cancellable
+ // Add information to death event
+ private static void populateFields(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) {
+ event.setReviveHealth(event.getEntity().getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).getValue());
+ event.setShouldPlayDeathSound(!victim.silentDeath && !victim.isSilent());
2021-10-03 03:42:30 +02:00
+ net.minecraft.sounds.SoundEvent soundEffect = victim.getDeathSound();
2021-06-11 14:02:28 +02:00
+ event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getBukkit(soundEffect) : null);
+ event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundSource().name()));
2021-06-16 00:24:12 +02:00
+ event.setDeathSoundVolume(victim.getSoundVolume());
2021-06-13 06:03:02 +02:00
+ event.setDeathSoundPitch(victim.getVoicePitch());
2021-06-11 14:02:28 +02:00
+ }
+
+ // Play death sound manually
+ private static void playDeathSound(net.minecraft.world.entity.LivingEntity victim, EntityDeathEvent event) {
+ if (event.shouldPlayDeathSound() && event.getDeathSound() != null && event.getDeathSoundCategory() != null) {
+ net.minecraft.world.entity.player.Player source = victim instanceof net.minecraft.world.entity.player.Player ? (net.minecraft.world.entity.player.Player) victim : null;
+ double x = event.getEntity().getLocation().getX();
+ double y = event.getEntity().getLocation().getY();
+ double z = event.getEntity().getLocation().getZ();
2021-06-13 06:03:02 +02:00
+ net.minecraft.sounds.SoundEvent soundEffect = org.bukkit.craftbukkit.CraftSound.getSoundEffect(event.getDeathSound());
+ net.minecraft.sounds.SoundSource soundCategory = net.minecraft.sounds.SoundSource.valueOf(event.getDeathSoundCategory().name());
2021-06-11 14:02:28 +02:00
+ victim.level.playSound(source, x, y, z, soundEffect, soundCategory, event.getDeathSoundVolume(), event.getDeathSoundPitch());
+ }
+ }
+ // Paper end
/**
* Server methods
*/