SPIGOT-7485: Allow air entity items since required for Vanilla logic

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot 2023-09-22 07:14:27 +10:00
parent 189292a2f0
commit fb7dc796d5

View File

@ -64,12 +64,7 @@
this.discard();
}
@@ -255,10 +275,15 @@
private static void merge(EntityItem entityitem, ItemStack itemstack, ItemStack itemstack1) {
ItemStack itemstack2 = merge(itemstack, itemstack1, 64);
- entityitem.setItem(itemstack2);
+ if (!itemstack2.isEmpty()) entityitem.setItem(itemstack2); // CraftBukkit - don't set empty stacks
@@ -259,6 +279,11 @@
}
private static void merge(EntityItem entityitem, ItemStack itemstack, EntityItem entityitem1, ItemStack itemstack1) {
@ -140,11 +135,3 @@
if (this.pickupDelay == 0 && (this.target == null || this.target.equals(entityhuman.getUUID())) && entityhuman.getInventory().add(itemstack)) {
entityhuman.take(this, i);
if (itemstack.isEmpty()) {
@@ -390,6 +460,7 @@
}
public void setItem(ItemStack itemstack) {
+ com.google.common.base.Preconditions.checkArgument(!itemstack.isEmpty(), "Cannot drop air"); // CraftBukkit
this.getEntityData().set(EntityItem.DATA_ITEM, itemstack);
}