Paper/Spigot-API-Patches/0026-Custom-replacement-for-eaten-items.patch
Spottedleaf 5c7081fecc Update upstream & fix some chunk related issues (#2177)
* Updated Upstream (Bukkit/CraftBukkit)

Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
45690fe9 SPIGOT-5047: Correct slot types for 1.14 inventories

CraftBukkit Changes:
4090d01f SPIGOT-5047: Correct slot types for 1.14 inventories
e8c08362 SPIGOT-5046: World#getLoadedChunks returning inaccessible cached chunks.
d445af3b SPIGOT-5067: Add item meta for 1.14 spawn eggs

* Bring Chunk load checks in-line with spigot

As of the last upstream merge spigot now checks ticket level status
when returning loaded chunks for a world from api. Now our checks
will respect that decision.

* Fix spawn ticket levels

Vanilla would keep the inner chunks of spawn available for ticking,
however my changes made all chunks non-ticking. Resolve by changing
ticket levels for spawn chunks inside the border to respect this
behavior.


* Make World#getChunkIfLoadedImmediately return only entity ticking chunks

Mojang appears to be using chunks with level > 33 (non-ticking chunks)
as cached chunks and not actually loaded chunks.

* Bring all loaded checks in line with spigot

Loaded chunks must be at least border  chunks, or level <= 33
2019-06-14 03:27:40 +01:00

52 lines
1.9 KiB
Diff

From f2d75b2305da564f7bf67db3354fbc8d06601225 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 c2793f3ef..373f4b5b5 100644
--- a/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
+++ b/src/main/java/org/bukkit/event/player/PlayerItemConsumeEvent.java
@@ -22,6 +22,7 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean isCancelled = false;
private ItemStack item;
+ @Nullable private ItemStack replacement; // Paper
/**
* @param player the player consuming
@@ -58,6 +59,29 @@ public class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable {
}
}
+ // 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;
--
2.21.0