SPIGOT-6093: Can't change ItemStack in EntityPickupItemEvent

This commit is contained in:
Shane Bee
2020-08-21 18:46:42 +10:00
committed by md_5
parent eaf0bace20
commit fe4efd19f5
3 changed files with 20 additions and 13 deletions

View File

@@ -85,7 +85,7 @@
this.velocityChanged();
this.f = (int) ((float) this.f - f);
if (this.f <= 0) {
@@ -285,6 +307,40 @@
@@ -285,6 +307,45 @@
Item item = itemstack.getItem();
int i = itemstack.getCount();
@@ -113,6 +113,11 @@
+ return;
+ }
+
+ // Update the ItemStack incase it was changed in the event
+ itemstack = this.getItemStack();
+ canHold = entityhuman.inventory.canHold(itemstack);
+ remaining = itemstack.getCount() - canHold;
+
+ itemstack.setCount(canHold + remaining); // = i
+
+ // Possibly < 0; fix here so we do not have to modify code below
@@ -126,7 +131,7 @@
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
entityhuman.receive(this, i);
if (itemstack.isEmpty()) {
@@ -328,7 +384,9 @@
@@ -328,7 +389,9 @@
}
public void setItemStack(ItemStack itemstack) {