mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-10 12:50:28 +01:00
48b6bfe2a6
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: c987938a SPIGOT-5180: Add Villager#sleep() and #wakeup() methods CraftBukkit Changes:7f33c6a2
SPIGOT-5196: Restore previous version behaviour regarding cancelled BlockBreakEvent6a5fc902
Improve diff in EntityHangingc98d61bf
SPIGOT-4712: Allow spawning of upwards or downwards facing item framesdb971477
SPIGOT-5199: Fix NPE if setting the book of the ItemMeta of a lecternb0ef3996
SPIGOT-4679 Fix black lines after book paragraphs1215188f
SPIGOT-5180: Add Villager#sleep() and #wakeup() methodsc03b2bef
SPIGOT-4975: NPE on WorldGenStronghold When Using Multiple Worlds65ea162c
Ensure Bukkit data pack is always up to date0b107b8d
MC-157395, SPIGOT-5193: Small armor stands do not drop loot6da0abca
SPIGOT-5195: Player loot table does not drop when keepInventory is on8b09d983
SPIGOT-5190: Superfluous EntityCombustEvent called when using fire aspect sword Spigot Changes: 1981d553 SPIGOT-5198: Catch more bad async operations 6a14ca46 Rebuild patches
78 lines
3.1 KiB
Diff
78 lines
3.1 KiB
Diff
From f7303a80c92c8bdc5705ebf7afcda3f5a802fc8a Mon Sep 17 00:00:00 2001
|
|
From: Aikar <aikar@aikar.co>
|
|
Date: Wed, 27 Mar 2019 23:01:33 -0400
|
|
Subject: [PATCH] PlayerDeathEvent#getItemsToKeep
|
|
|
|
Exposes a mutable array on items a player should keep on death
|
|
|
|
Example Usage: https://gist.github.com/aikar/5bb202de6057a051a950ce1f29feb0b4
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
index a191d6246..18695d9b5 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
|
|
@@ -510,6 +510,46 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
});
|
|
}
|
|
|
|
+ // Paper start - process inventory
|
|
+ private static void processKeep(org.bukkit.event.entity.PlayerDeathEvent event, NonNullList<ItemStack> inv) {
|
|
+ List<org.bukkit.inventory.ItemStack> itemsToKeep = event.getItemsToKeep();
|
|
+ if (inv == null) {
|
|
+ // remainder of items left in toKeep - plugin added stuff on death that wasn't in the initial loot?
|
|
+ if (!itemsToKeep.isEmpty()) {
|
|
+ for (org.bukkit.inventory.ItemStack itemStack : itemsToKeep) {
|
|
+ event.getEntity().getInventory().addItem(itemStack);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ for (int i = 0; i < inv.size(); ++i) {
|
|
+ ItemStack item = inv.get(i);
|
|
+ if (EnchantmentManager.shouldNotDrop(item) || itemsToKeep.isEmpty() || item.isEmpty()) {
|
|
+ inv.set(i, ItemStack.NULL_ITEM);
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ final org.bukkit.inventory.ItemStack bukkitStack = item.getBukkitStack();
|
|
+ boolean keep = false;
|
|
+ final Iterator<org.bukkit.inventory.ItemStack> iterator = itemsToKeep.iterator();
|
|
+ while (iterator.hasNext()) {
|
|
+ final org.bukkit.inventory.ItemStack itemStack = iterator.next();
|
|
+ if (bukkitStack.equals(itemStack)) {
|
|
+ iterator.remove();
|
|
+ keep = true;
|
|
+ break;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ if (!keep) {
|
|
+ inv.set(i, ItemStack.NULL_ITEM);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+ // Paper end
|
|
+
|
|
@Override
|
|
public void die(DamageSource damagesource) {
|
|
boolean flag = this.world.getGameRules().getBoolean(GameRules.SHOW_DEATH_MESSAGES);
|
|
@@ -594,7 +634,12 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
|
|
this.releaseShoulderEntities();
|
|
// we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
|
|
if (!event.getKeepInventory()) {
|
|
- this.inventory.clear();
|
|
+ // Paper start - replace logic
|
|
+ for (NonNullList<ItemStack> inv : this.inventory.getComponents()) {
|
|
+ processKeep(event, inv);
|
|
+ }
|
|
+ processKeep(event, null);
|
|
+ // Paper end
|
|
}
|
|
|
|
this.setSpectatorTarget(this); // Remove spectated target
|
|
--
|
|
2.22.0
|
|
|