mirror of
https://github.com/PaperMC/Paper.git
synced 2025-03-19 13:38:44 +01:00
SPIGOT-5294: Cancelled EntityPickupItemEvent and PlayerPickupItemEvent alter on-ground stacks
By: md_5 <git@md-5.net>
This commit is contained in:
parent
147ff6b1e3
commit
5c6a8f66c2
1 changed files with 5 additions and 3 deletions
|
@ -97,7 +97,7 @@
|
||||||
this.velocityChanged();
|
this.velocityChanged();
|
||||||
this.f = (int) ((float) this.f - f);
|
this.f = (int) ((float) this.f - f);
|
||||||
if (this.f <= 0) {
|
if (this.f <= 0) {
|
||||||
@@ -267,6 +289,38 @@
|
@@ -267,6 +289,40 @@
|
||||||
Item item = itemstack.getItem();
|
Item item = itemstack.getItem();
|
||||||
int i = itemstack.getCount();
|
int i = itemstack.getCount();
|
||||||
|
|
||||||
|
@ -112,6 +112,7 @@
|
||||||
+ playerEvent.setCancelled(!entityhuman.canPickUpLoot);
|
+ playerEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||||
+ this.world.getServer().getPluginManager().callEvent(playerEvent);
|
+ this.world.getServer().getPluginManager().callEvent(playerEvent);
|
||||||
+ if (playerEvent.isCancelled()) {
|
+ if (playerEvent.isCancelled()) {
|
||||||
|
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
@ -120,10 +121,11 @@
|
||||||
+ entityEvent.setCancelled(!entityhuman.canPickUpLoot);
|
+ entityEvent.setCancelled(!entityhuman.canPickUpLoot);
|
||||||
+ this.world.getServer().getPluginManager().callEvent(entityEvent);
|
+ this.world.getServer().getPluginManager().callEvent(entityEvent);
|
||||||
+ if (entityEvent.isCancelled()) {
|
+ if (entityEvent.isCancelled()) {
|
||||||
|
+ itemstack.setCount(i); // SPIGOT-5294 - restore count
|
||||||
+ return;
|
+ return;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ itemstack.setCount(canHold + remaining);
|
+ itemstack.setCount(canHold + remaining); // = i
|
||||||
+
|
+
|
||||||
+ // Possibly < 0; fix here so we do not have to modify code below
|
+ // Possibly < 0; fix here so we do not have to modify code below
|
||||||
+ this.pickupDelay = 0;
|
+ this.pickupDelay = 0;
|
||||||
|
@ -136,7 +138,7 @@
|
||||||
if (this.pickupDelay == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
|
if (this.pickupDelay == 0 && (this.owner == null || 6000 - this.age <= 200 || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
|
||||||
entityhuman.receive(this, i);
|
entityhuman.receive(this, i);
|
||||||
if (itemstack.isEmpty()) {
|
if (itemstack.isEmpty()) {
|
||||||
@@ -309,7 +363,9 @@
|
@@ -309,7 +365,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemStack(ItemStack itemstack) {
|
public void setItemStack(ItemStack itemstack) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue