PaperMC/Spigot-Server-Patches/0148-PlayerPickupItemEvent-setFlyAtPlayer.patch
Gabscap 7ae47d4eb3
[CI-SKIP] Remove Waving banner fix (#4786)
Mojang fixed it in MC-63720
2020-11-19 10:15:16 -05:00

46 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: BillyGalbreath <Blake.Galbreath@GMail.com>
Date: Sun, 7 May 2017 06:26:09 -0500
Subject: [PATCH] PlayerPickupItemEvent#setFlyAtPlayer
diff --git a/src/main/java/net/minecraft/server/EntityItem.java b/src/main/java/net/minecraft/server/EntityItem.java
index 507ad727ce62a30b1120104b16737e21b777d7ae..57a2fdfbcd04345901f8f596c68932b4942790a1 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -336,6 +336,7 @@ public class EntityItem extends Entity {
// CraftBukkit start - fire PlayerPickupItemEvent
int canHold = entityhuman.inventory.canHold(itemstack);
int remaining = i - canHold;
+ boolean flyAtPlayer = false; // Paper
if (this.pickupDelay <= 0 && canHold > 0) {
itemstack.setCount(canHold);
@@ -343,8 +344,14 @@ public class EntityItem extends Entity {
PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
playerEvent.setCancelled(!entityhuman.canPickUpLoot);
this.world.getServer().getPluginManager().callEvent(playerEvent);
+ flyAtPlayer = playerEvent.getFlyAtPlayer(); // Paper
if (playerEvent.isCancelled()) {
itemstack.setCount(i); // SPIGOT-5294 - restore count
+ // Paper Start
+ if (flyAtPlayer) {
+ entityhuman.receive(this, i);
+ }
+ // Paper End
return;
}
@@ -374,7 +381,11 @@ public class EntityItem extends Entity {
// CraftBukkit end
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(entityhuman.getUniqueID())) && entityhuman.inventory.pickup(itemstack)) {
- entityhuman.receive(this, i);
+ // Paper Start
+ if (flyAtPlayer) {
+ entityhuman.receive(this, i);
+ }
+ // Paper End
if (itemstack.isEmpty()) {
this.die();
itemstack.setCount(i);