Paper/patches/server/0951-Remove-CraftItemStack-setAmount-null-assignment.patch
Nassim Jahnke bf92f3e4db
Updated Upstream (Bukkit/CraftBukkit)
Upstream has released updates that appear 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:
9153f77e PR-841: Remove incorrect ClickType.CONTROL_DROP from ClickType#isShiftClick
bceda6ab PR-840: Adjust annotations in Display entity interface
a6b85ac3 PR-835: Add Jukebox#hasRecord() and #startPlaying(), clarify #setRecord()

CraftBukkit Changes:
e142fb9fd SPIGOT-7188: ChunkSnapshot biome y coordinate doesn't match chunk biome y coord
eff1743b9 SPIGOT-7313: More accurately edit data on Jukeboxes
2023-03-30 15:40:15 +02:00

31 lines
1.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josh Roy <joshroy126@gmail.com>
Date: Mon, 23 Jan 2023 19:19:01 -0500
Subject: [PATCH] Remove CraftItemStack#setAmount null assignment
This creates a problem with Paper's item serialization
api where deserialized items, which are internally
created as a CraftItemStack, will be completely lost if
#setAmount(0) is invoked (since the underlying handle
is set to null), while a regular Bukkit ItemStack
simply sets the amount field to zero, retaining the
item's data.
Vanilla treats items with zero amounts the same as items
with less than zero amounts, so this code doesn't create
a problem with operations on the vanilla ItemStack.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
index d95d37d9dedbd9f74311b47826a74b16ba6ce3e9..f45e4acee69bd95ff2e41feaf44f5414d2e40df0 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -146,7 +146,7 @@ public final class CraftItemStack extends ItemStack {
}
this.handle.setCount(amount);
- if (amount == 0) {
+ if (false && amount == 0) { // Paper - remove CraftItemStack#setAmount null assignment
this.handle = null;
}
}