aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/api/0030-Custom-replacement-for-eaten-items.patch
blob: f7a9207fb381e967370cb1608c18f4edc9fe0430 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Jedediah Smith <jedediah@silencegreys.com>
Date: Sun, 21 Jun 2015 15:05:21 -0400
Subject: [PATCH] Custom replacement for eaten items


diff --git a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
index 5c054eb531e3caf17c179aff6a712fb8c33d8f77..6110d0417340710333b44312d82c7bd5165a8954 100644
--- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
@@ -24,6 +24,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
     private boolean isCancelled = false;
     private ItemStack item;
     private final EquipmentSlot hand;
+    @Nullable private ItemStack replacement; // Paper
 
     /**
      * @param player the player consuming
@@ -82,6 +83,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
         return hand;
     }
 
+    // Paper start
+    /**
+     * Return the custom item stack that will replace the consumed item, or null if no
+     * custom replacement has been set (which means the default replacement will be used).
+     *
+     * @return The custom item stack that will replace the consumed item or null
+     */
+    @Nullable
+    public ItemStack getReplacement() {
+        return this.replacement;
+    }
+
+    /**
+     * Set a custom item stack to replace the consumed item. Pass null to clear any custom
+     * stack that has been set and use the default replacement.
+     *
+     * @param replacement Replacement item to set, null to clear any custom stack and use default
+     */
+    public void setReplacement(@Nullable ItemStack replacement) {
+        this.replacement = replacement;
+    }
+    // Paper end
+
     @Override
     public boolean isCancelled() {
         return this.isCancelled;