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, 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
|
2022-07-27 19:49:24 +00:00
|
|
|
index bd78031511b8c7facc3f61f3a23cbf4264fa2d0c..6ecab1dd5932c4c346cde987cb9463b00a32d385 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
|
2021-11-23 14:03:50 +00:00
|
|
|
@@ -36,6 +36,7 @@ import net.minecraft.util.Mth;
|
2021-06-11 12:02:28 +00:00
|
|
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
|
|
|
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
|
|
// CraftBukkit end
|
|
|
|
+import org.bukkit.event.player.PlayerAttemptPickupItemEvent; // Paper
|
|
|
|
|
|
|
|
public class ItemEntity extends Entity {
|
|
|
|
|
2022-07-27 19:49:24 +00:00
|
|
|
@@ -390,6 +391,22 @@ public class ItemEntity extends Entity {
|
2021-06-11 12:02:28 +00: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
|