testserver/Spigot-Server-Patches/0149-PlayerPickupItemEvent-...

47 lines
2.3 KiB
Diff
Raw Normal View History

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
2020-06-25 13:11:48 +00:00
index 159552192c2a6d62fb205ed5973f89a16e619d94..2546a706ef107fd94e4c17c10091d6c0a7241a70 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
2020-06-25 13:11:48 +00:00
@@ -331,6 +331,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);
2020-06-25 13:11:48 +00:00
@@ -338,8 +339,14 @@ public class EntityItem extends Entity {
2017-07-28 13:45:16 +00:00
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;
}
2020-06-25 13:11:48 +00:00
@@ -363,7 +370,11 @@ public class EntityItem extends Entity {
// CraftBukkit end
2019-12-11 23:43:22 +00:00
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);