3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-15 04:20:04 +01:00
Paper/patches/server/0139-PlayerPickupItemEvent-setFlyAtPlayer.patch

47 Zeilen
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/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
index 6df6204c9d4099afeb8ff07dd747f756d8e380d6..68fdfba22ebb35023299c776d4764d4f1555f435 100644
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
@@ -378,6 +378,7 @@ public class ItemEntity extends Entity {
// CraftBukkit start - fire PlayerPickupItemEvent
int canHold = player.getInventory().canHold(itemstack);
int remaining = i - canHold;
+ boolean flyAtPlayer = false; // Paper
if (this.pickupDelay <= 0 && canHold > 0) {
itemstack.setCount(canHold);
@@ -385,8 +386,14 @@ public class ItemEntity extends Entity {
PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
this.level.getCraftServer().getPluginManager().callEvent(playerEvent);
+ flyAtPlayer = playerEvent.getFlyAtPlayer(); // Paper
if (playerEvent.isCancelled()) {
itemstack.setCount(i); // SPIGOT-5294 - restore count
+ // Paper Start
+ if (flyAtPlayer) {
+ player.take(this, i);
+ }
+ // Paper End
return;
}
@@ -416,7 +423,11 @@ public class ItemEntity extends Entity {
// CraftBukkit end
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(player.getUUID())) && player.getInventory().add(itemstack)) {
- player.take(this, i);
+ // Paper Start
+ if (flyAtPlayer) {
+ player.take(this, i);
+ }
+ // Paper End
if (itemstack.isEmpty()) {
this.discard();
itemstack.setCount(i);