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