aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
diff options
context:
space:
mode:
authormaxcom1 <[email protected]>2024-03-23 22:26:17 +0100
committerGitHub <[email protected]>2024-03-23 17:26:17 -0400
commitb6001403e9703cadaa6e8c8558e732b91c3c6d6e (patch)
treea8c57bbc334a8ad48d4ad2b43db335667b142bee /patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
parent9ec7dfcbc41c6e625de0050b6997160a75df9f44 (diff)
downloadPaper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.tar.gz
Paper-b6001403e9703cadaa6e8c8558e732b91c3c6d6e.zip
Add methods to change entity physics (#10334)
Diffstat (limited to 'patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch')
-rw-r--r--patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch30
1 files changed, 30 insertions, 0 deletions
diff --git a/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch b/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
new file mode 100644
index 0000000000..8d4f6df398
--- /dev/null
+++ b/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Josh Roy <[email protected]>
+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 6725c0824b986885c8aade846f6e159986ffbe59..312e756843f62371048a4d8de9deb024bd9846a7 100644
+--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+@@ -157,7 +157,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;
+ }
+ }