Paper/patches/unapplied/server/0140-PlayerPickupItemEvent-setFlyAtPlayer.patch

47 Zeilen
2.3 KiB
Diff

2021-06-11 14:02:28 +02:00
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
2021-06-12 12:26:21 +02:00
index 9611388a6aeebb86b19d89c526f53dfed4d3ed27..d17af2ec8f72bf0cbe5928e7a83c06ba5ad4503d 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
2021-06-12 12:26:21 +02:00
@@ -379,6 +379,7 @@ public class ItemEntity extends Entity {
2021-06-11 14:02:28 +02:00
// CraftBukkit start - fire PlayerPickupItemEvent
2021-06-12 12:26:21 +02:00
int canHold = player.getInventory().canHold(itemstack);
2021-06-11 14:02:28 +02:00
int remaining = i - canHold;
+ boolean flyAtPlayer = false; // Paper
if (this.pickupDelay <= 0 && canHold > 0) {
itemstack.setCount(canHold);
2021-06-12 12:26:21 +02:00
@@ -386,8 +387,14 @@ public class ItemEntity extends Entity {
2021-06-11 14:02:28 +02:00
PlayerPickupItemEvent playerEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
2021-06-12 12:26:21 +02:00
playerEvent.setCancelled(!playerEvent.getPlayer().getCanPickupItems());
2021-06-11 14:02:28 +02:00
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;
}
2021-06-12 12:26:21 +02:00
@@ -417,7 +424,11 @@ public class ItemEntity extends Entity {
2021-06-11 14:02:28 +02:00
// CraftBukkit end
2021-06-12 12:26:21 +02:00
if (this.pickupDelay == 0 && (this.owner == null || this.owner.equals(player.getUUID())) && player.getInventory().add(itemstack)) {
2021-06-11 14:02:28 +02:00
- player.take(this, i);
+ // Paper Start
+ if (flyAtPlayer) {
+ player.take(this, i);
+ }
+ // Paper End
if (itemstack.isEmpty()) {
2021-06-12 12:26:21 +02:00
this.discard();
2021-06-11 14:02:28 +02:00
itemstack.setCount(i);