Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-11-15 20:40:07 +01:00
cc6fd371b2
Fixes #6357 Closes #6508 Closes #6358
42 Zeilen
1.8 KiB
Diff
42 Zeilen
1.8 KiB
Diff
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
|
|
index d17af2ec8f72bf0cbe5928e7a83c06ba5ad4503d..54025e401eb02fceb47afb182f0ede620ca23a8d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/item/ItemEntity.java
|
|
@@ -37,6 +37,7 @@ import net.minecraft.stats.Stats;
|
|
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 {
|
|
|
|
@@ -381,6 +382,22 @@ public class ItemEntity extends Entity {
|
|
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
|