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, 11 Jun 2017 16:30:30 -0500
|
|
|
|
Subject: [PATCH] PlayerAttemptPickupItemEvent
|
|
|
|
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
2023-06-07 21:19:26 +02:00
|
|
|
index 8357ef35c374c6a6602eb96d4281da0210aea757..04b4c7af20d6aa9924fb1d345f11cb51dcadc708 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
|
2023-03-14 19:36:39 +01:00
|
|
|
@@ -35,6 +35,7 @@ import net.minecraft.stats.Stats;
|
2021-06-11 14:02:28 +02:00
|
|
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
|
|
// CraftBukkit end
|
|
|
|
+import org.bukkit.event.player.PlayerAttemptPickupItemEvent; // Paper
|
|
|
|
|
2023-03-14 19:36:39 +01:00
|
|
|
public class ItemEntity extends Entity implements TraceableEntity {
|
2021-06-11 14:02:28 +02:00
|
|
|
|
2023-06-07 21:19:26 +02:00
|
|
|
@@ -401,6 +402,22 @@ public class ItemEntity extends Entity implements TraceableEntity {
|
2021-06-11 14:02:28 +02:00
|
|
|
int remaining = i - canHold;
|
|
|
|
boolean flyAtPlayer = false; // Paper
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ if (this.pickupDelay <= 0) {
|
|
|
|
+ PlayerAttemptPickupItemEvent attemptEvent = new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
|
|
|
|
+ this.level.getCraftServer().getPluginManager().callEvent(attemptEvent);
|
|
|
|
+
|
|
|
|
+ flyAtPlayer = attemptEvent.getFlyAtPlayer();
|
|
|
|
+ if (attemptEvent.isCancelled()) {
|
|
|
|
+ if (flyAtPlayer) {
|
|
|
|
+ player.take(this, i);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
if (this.pickupDelay <= 0 && canHold > 0) {
|
|
|
|
itemstack.setCount(canHold);
|
|
|
|
// Call legacy event
|