3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 20:40:07 +01:00
Paper/Spigot-Server-Patches/0214-PlayerPickupItemEvent-setFlyAtPlayer.patch
2017-06-25 18:00:32 -05:00

50 Zeilen
2.1 KiB
Diff

From 063ea4b06d53bcfedb783b7b937482af565db81d 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 dc52ef45b..fa207c579 100644
--- a/src/main/java/net/minecraft/server/EntityItem.java
+++ b/src/main/java/net/minecraft/server/EntityItem.java
@@ -329,6 +329,7 @@ public class EntityItem extends Entity implements HopperPusher {
// 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);
@@ -336,8 +337,14 @@ public class EntityItem extends Entity implements HopperPusher {
event.setCancelled(!entityhuman.canPickUpLoot);
this.world.getServer().getPluginManager().callEvent(event);
itemstack.setCount(canHold + remaining);
+ flyAtPlayer = event.getFlyAtPlayer(); // Paper
if (event.isCancelled()) {
+ // Paper Start
+ if (flyAtPlayer) {
+ entityhuman.receive(this, i);
+ }
+ // Paper End
return;
}
@@ -347,7 +354,11 @@ public class EntityItem extends Entity implements HopperPusher {
// CraftBukkit end
if (this.pickupDelay == 0 && (this.h == null || 6000 - this.age <= 200 || this.h.equals(entityhuman.getName())) && 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);
--
2.13.0