Paper/Spigot-Server-Patches/0300-Improve-death-events.patch

446 lines
21 KiB
Diff
Raw Normal View History

Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
From 5d6dc2bb82c80b978eaccdeb9e69dbf34d723805 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 84c3ea9d00..f563a7b630 100644
--- a/src/main/java/net/minecraft/server/CombatTracker.java
+++ b/src/main/java/net/minecraft/server/CombatTracker.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) 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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
@@ -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;
Updated Upstream (Bukkit/CraftBukkit/Spigot) 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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 7811beb807..f9b097fd6f 100644
--- a/src/main/java/net/minecraft/server/Entity.java
+++ b/src/main/java/net/minecraft/server/Entity.java
@@ -1517,6 +1517,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);
@@ -2410,6 +2411,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
2018-09-08 23:12:58 +00:00
this.fallDistance = 0.0F;
}
+ public void onKill(EntityLiving entityLiving) { this.b(entityLiving); } // Paper - OBFHELPER
public void b(EntityLiving entityliving) {}
2019-05-05 11:12:32 +00:00
protected void i(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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 627925e3ba..e516db2701 100644
--- a/src/main/java/net/minecraft/server/EntityArmorStand.java
+++ b/src/main/java/net/minecraft/server/EntityArmorStand.java
@@ -683,7 +683,8 @@ public class EntityArmorStand extends EntityLiving {
2019-05-05 11:12:32 +00:00
@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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 85231309fd..97059b8239 100644
--- a/src/main/java/net/minecraft/server/EntityFox.java
+++ b/src/main/java/net/minecraft/server/EntityFox.java
@@ -597,15 +597,25 @@ public class EntityFox extends EntityAnimal {
}
@Override
- protected void d(DamageSource damagesource) {
2019-05-07 15:20:32 +00:00
- ItemStack itemstack = this.getEquipment(EnumItemSlot.MAINHAND);
+ protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper
2019-05-07 15:20:32 +00:00
+ ItemStack itemstack = this.getEquipment(EnumItemSlot.MAINHAND).cloneItemStack(); // Paper
+
+ // Paper start - Cancellable death event
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = super.processDeath(damagesource);
+
+ // Below is code to drop
+
+ if (deathEvent == null || deathEvent.isCancelled()) {
+ return deathEvent;
+ }
+ // Paper end
2019-05-07 15:20:32 +00:00
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) {
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
diff --git a/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java b/src/main/java/net/minecraft/server/EntityHorseChestedAbstract.java
index 2483cfd28a..2a988366cd 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index b09712ca91..1e53af2cce 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
2019-05-05 11:12:32 +00:00
@@ -85,7 +85,7 @@ public abstract class EntityLiving extends Entity {
protected float aV;
protected float aW;
protected float aX;
- protected int aY;
+ protected int aY; protected int getKillCount() { return this.aY; } // Paper - OBFHELPER
public float lastDamage;
2019-05-05 11:12:32 +00:00
protected boolean jumping;
public float bb;
@@ -128,6 +128,7 @@ public abstract class EntityLiving extends Entity {
public boolean collides = true;
public boolean canPickUpLoot;
2018-09-08 23:12:58 +00: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() {
2019-05-27 23:01:45 +00:00
@@ -1185,13 +1186,17 @@ public abstract class EntityLiving extends Entity {
2018-09-08 23:12:58 +00:00
if (this.getHealth() <= 0.0F) {
2019-05-05 11:12:32 +00:00
if (!this.f(damagesource)) {
- SoundEffect soundeffect = this.getSoundDeath();
2018-09-08 23:12:58 +00:00
+ // Paper start - moved into CraftEventFactory event caller for cancellable death event
2019-05-05 11:12:32 +00:00
+ //SoundEffect soundeffect = this.getSoundDeath();
2018-09-08 23:12:58 +00:00
- if (flag1 && soundeffect != null) {
- this.a(soundeffect, this.getSoundVolume(), this.cV());
2018-09-08 23:12:58 +00:00
- }
+ //if (flag1 && soundeffect != null) {
+ // this.a(soundeffect, this.getSoundVolume(), this.cV());
2018-09-08 23:12:58 +00:00
+ //}
+ 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);
@@ -1329,6 +1334,7 @@ public abstract class EntityLiving extends Entity {
Entity entity = damagesource.getEntity();
2019-05-05 11:12:32 +00:00
EntityLiving entityliving = this.getKillingEntity();
+ /* // Paper - move down to make death event cancellable
if (this.aY >= 0 && entityliving != null) {
entityliving.a(this, this.aY, damagesource);
}
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -1340,14 +1346,32 @@ public abstract class EntityLiving extends Entity {
if (this.isSleeping()) {
2019-07-20 04:01:24 +00:00
this.dy();
}
+ */ // Paper
this.killed = true;
- this.getCombatTracker().g();
+ //this.getCombatTracker().g();
if (!this.world.isClientSide) {
2019-05-05 11:12:32 +00:00
- this.d(damagesource);
+ org.bukkit.event.entity.EntityDeathEvent deathEvent = this.d(damagesource);
+ if (deathEvent == null || !deathEvent.isCancelled()) {
2019-05-05 11:12:32 +00:00
+ if (this.getKillCount() >= 0 && entityliving != null) {
+ entityliving.runKillTrigger(this, this.getKillCount(), damagesource);
+ }
+ if (entity != null) {
+ entity.onKill(this);
+ }
+ if (this.isSleeping()) {
2019-07-20 04:01:24 +00:00
+ this.dy();
2019-05-05 11:12:32 +00:00
+ }
+ this.getCombatTracker().reset();
+ } else {
+ this.killed = false;
+ this.setHealth((float) deathEvent.getReviveHealth());
+ }
2019-05-05 11:12:32 +00:00
+ // Paper end
+
2019-05-05 11:12:32 +00:00
boolean flag = false;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
- if (entityliving instanceof EntityWither) {
+ if (this.killed && entityliving instanceof EntityWither) {
if (this.world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
BlockPosition blockposition = new BlockPosition(this.locX, this.locY, this.locZ);
IBlockData iblockdata = Blocks.WITHER_ROSE.getBlockData();
@@ -1366,12 +1390,15 @@ public abstract class EntityLiving extends Entity {
}
}
+ if (this.killed) { // Paper
this.world.broadcastEntityEffect(this, (byte) 3);
this.setPose(EntityPose.DYING);
+ } // Paper
}
}
2019-05-05 11:12:32 +00:00
- protected void d(DamageSource damagesource) {
+ protected org.bukkit.event.entity.EntityDeathEvent processDeath(DamageSource damagesource) { return d(damagesource); } // Paper - OBFHELPER
2019-05-05 11:12:32 +00:00
+ protected org.bukkit.event.entity.EntityDeathEvent d(DamageSource damagesource) { // Paper
Entity entity = damagesource.getEntity();
int i;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -1384,21 +1411,24 @@ public abstract class EntityLiving extends Entity {
2019-05-05 11:12:32 +00:00
boolean flag = this.lastDamageByPlayerTime > 0;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
this.cF(); // CraftBukkit - from below // PAIL
+ org.bukkit.event.entity.EntityDeathEvent deathEvent; // Paper
if (this.isDropExperience() && this.world.getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
2019-05-05 11:12:32 +00:00
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
}
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
+ this.postDeathDropItems(deathEvent); // Paper
+ this.drops = new ArrayList<>(); // Paper
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
- // this.cF();// CraftBukkit - moved up
2019-05-05 11:12:32 +00:00
+ return deathEvent; // Paper
}
protected void cF() {}
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
+ 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
protected void dropDeathLoot(DamageSource damagesource, int i, boolean flag) {}
@@ -1449,6 +1479,7 @@ public abstract class EntityLiving extends Entity {
2019-05-05 23:24:37 +00:00
return SoundEffects.ENTITY_GENERIC_HURT;
}
+ public final SoundEffect getDeathSoundEffect() { return this.getSoundDeath(); } // Paper - OBFHELPER
@Nullable
protected SoundEffect getSoundDeath() {
return SoundEffects.ENTITY_GENERIC_DEATH;
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
@@ -1898,10 +1929,12 @@ public abstract class EntityLiving extends Entity {
2019-05-05 23:24:37 +00:00
}
+ public final float getDeathSoundVolume() { return this.getSoundVolume(); } // Paper - OBFHELPER
protected float getSoundVolume() {
return 1.0F;
}
+ public float getSoundPitch() { return cV();} // Paper - OBFHELPER
protected float cV() {
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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index dcd48d8b3d..d7bc6e3297 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
2019-05-06 02:58:04 +00:00
@@ -75,6 +75,10 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2018-09-09 18:38:27 +00:00
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;
@@ -533,6 +537,15 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2018-09-08 23:12:58 +00:00
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
Updated Upstream (Bukkit/CraftBukkit/Spigot) 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 Warning: this commit contains more mapping changes from upstream, As always, ensure that you have working backups and test this build before deployment; Developers working on paper will, yet again, need to delete their work/Minecraft/1.13.2 folder Bukkit Changes: 7fca5fd4 SPIGOT-4558: Preserve user order in the face of copied defaults in configurations 15c9b1eb Ignore spurious slot IDs sent by client, e.g. in enchanting tables 5d2a10c5 SPIGOT-3747: Add API for force loaded chunks d6dd2bb3 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent 771db4aa SPIGOT-794: Call EntityPlaceEvent for Minecart placement 55462509 Add InventoryView#getSlotType 2f3ce5b6 Remove EntityTransformEvent and CustomItemTagContainer from draft API f04ad7b6 Make ProjectileLaunchEvent extend EntitySpawnEvent ccb85808 Define EntitySpawnEvent b8cc3ebe Add PlayerItemDamageEvent 184a495d Ease ClassLoader Deadlocks Where Possible 11ac4728 Expand Boolean Prompt Values in Conversation API aae62d51 Added getAllSessionData() to the Conversation API. 9290ff91 Add InventoryView#getInventory API 995e530f Add API to get / set base arrow damage CraftBukkit Changes: c4a67eed SPIGOT-4556: Fix plugins closing inventory during drop events 5be2ddcb Replace version constants with methods to prevent compiler inlining a5b9c7b3 Use API method to create offset command completions 2bc7d1df SPIGOT-3747: Add API for force loaded chunks a408f375 SPIGOT-3538: Add getHitBlockFace for ProjectileHitEvent b54b9409 SPIGOT-2864: Make Arrow / Item setTicksLived behave like FallingBlock 79ded7a8 SPIGOT-1811: Death message not shown on respawn screen b4a4f15d SPIGOT-943: InventoryCloseEvent called on death regardless of open inventory 0afed592 SPIGOT-794: Call EntityPlaceEvent for Minecart placement 2b2d084a Add InventoryView#getSlotType 01a9959a Do not use deprecated ItemSpawnEvent constructor 9642498d SPIGOT-4547: Call EntitySpawnEvent as general spawn fallback event 963f4a5f Add PlayerItemDamageEvent 63db0445 Add API to get / set base arrow damage 531c25d7 Add CraftMagicNumbers.MAPPINGS_VERSION for use by NMS plugins d05c8b14 Mappings Update bd36e200 SPIGOT-4551: Ignore invalid attribute modifier slots Spigot Changes: 518206a1 Remove redundant trove depend 1959ad21 MC-11211,SPIGOT-4552: Fix placing double slabs at y = 255 29ab5e43 SPIGOT-3661: Allow arguments in restart-script 7cc46316 SPIGOT-852: Growth modifiers for beetroots, potatoes, carrots 82e117e1 Squelch "fatal: Resolve operation not in progress" message 0a1a68e7 Mappings Update & Patch Rebuild
2019-01-01 03:15:55 +00:00
// SPIGOT-943 - only call if they have an inventory open
if (this.activeContainer != this.defaultContainer) {
@@ -686,8 +699,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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 73cb64e09d..9f317ff2e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftSound.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftSound.java
2019-05-05 11:12:32 +00:00
@@ -806,6 +806,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) {
2018-09-08 23:12:58 +00:00
+ 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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 2c99a1e9df..e9458dc65f 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1722,7 +1722,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
Updated Upstream (Bukkit/CraftBukkit/Spigot) (#2415) * fixup patch and rebuild * Updated Upstream (Bukkit/CraftBukkit/Spigot) 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: bde198c9 SPIGOT-5246: PlayerQuitEvent.get/setQuitMessage() is incorrectly marked as NotNull 24ad5a79 SPIGOT-5240: Vector.angle not valid for angles very close to each other a143db9a SPIGOT-5231: ShotAtAngle API for Fireworks 10db5c3d SPIGOT-5226: Update Javadoc of PlayerDeathEvent CraftBukkit Changes: 1ec1b05e SPIGOT-5245: Unneeded cast to WorldNBTStorage in CraftWorld#getWorldFolder e5e8eec2 SPIGOT-5241: setAttributeModifiers does not work on untouched stack 803eaa31 SPIGOT-5231: ShotAtAngle API for Fireworks 7881d2ae SPIGOT-5237: Horses, pigs do not drop their inventory 06efc9ec Don't accept connections until all plugins have enabled da62a66a SPIGOT-5225: World handle isn't closed if world is unloaded without saving 104b3831 SPIGOT-5222: Cannot get Long values from Entity memory f0b3fe43 SPIGOT-5220: Server CPU usage reaches 100% when stdin is null Spigot Changes: e5b1b5db SPIGOT-5235: Destroy expired area effect clouds / fireworks that are inactive cbcc8e87 Make region files more reliable to write to 8887c5f4 Remove redundant late-bind option dac29063 Rebuild patches * Preserve old flush on save flag for reliable regionfiles Originally this patch was in paper * Fix some issues with the death event - Entities potentially entering a glitched state to the client where they appear to be falling over - Donkeys losing their chest if the event was cancelled (only an issue since the upstream merge) - Some wither death logic running for an entity killed by a wither
2019-08-05 16:35:40 +00:00
index 5309a4e304..4074100c44 100644
--- a/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
+++ b/src/main/java/org/bukkit/craftbukkit/event/CraftEventFactory.java
@@ -736,9 +736,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()) {
@@ -754,8 +761,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();
@@ -772,6 +786,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());
2019-05-05 23:24:37 +00:00
+ net.minecraft.server.SoundEffect soundEffect = victim.getDeathSoundEffect();
+ event.setDeathSound(soundEffect != null ? org.bukkit.craftbukkit.CraftSound.getSoundByEffect(soundEffect) : null);
2019-05-05 23:24:37 +00:00
+ event.setDeathSoundCategory(org.bukkit.SoundCategory.valueOf(victim.getSoundCategory().name()));
+ event.setDeathSoundVolume(victim.getDeathSoundVolume());
2019-05-05 23:24:37 +00:00
+ 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();
2019-05-05 23:24:37 +00:00
+ 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
*/
--
2.22.0