1
0
Fork 0
mirror of https://github.com/PaperMC/Paper.git synced 2024-12-22 14:35:11 +01:00
PaperMC/patches/server/0133-PlayerAttemptPickupItemEvent.patch

42 lines
1.9 KiB
Diff
Raw Normal View History

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
2024-10-22 22:38:26 +02:00
index 92b52ccca3ec7aaab1ffcdc1b85bf6b3e507087f..75ebf09777e19645eee296a9edabac39c858ffb9 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
2024-06-13 20:09:28 +02:00
@@ -40,6 +40,7 @@ import org.bukkit.event.entity.EntityPickupItemEvent;
import org.bukkit.event.entity.EntityRemoveEvent;
2021-06-11 14:02:28 +02:00
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
2024-10-22 22:38:26 +02:00
@@ -454,6 +455,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 - PlayerAttemptPickupItemEvent
2021-06-11 14:02:28 +02:00
+ if (this.pickupDelay <= 0) {
+ PlayerAttemptPickupItemEvent attemptEvent = new PlayerAttemptPickupItemEvent((org.bukkit.entity.Player) player.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
2023-06-08 00:12:41 +02:00
+ this.level().getCraftServer().getPluginManager().callEvent(attemptEvent);
2021-06-11 14:02:28 +02:00
+
+ flyAtPlayer = attemptEvent.getFlyAtPlayer();
+ if (attemptEvent.isCancelled()) {
+ if (flyAtPlayer) {
+ player.take(this, i);
+ }
+
+ return;
+ }
+ }
+ // Paper end - PlayerAttemptPickupItemEvent
2021-06-11 14:02:28 +02:00
+
if (this.pickupDelay <= 0 && canHold > 0) {
itemstack.setCount(canHold);
// Call legacy event