aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server
diff options
context:
space:
mode:
authorOwen <[email protected]>2024-04-12 17:16:22 -0400
committerGitHub <[email protected]>2024-04-12 17:16:22 -0400
commit4445d23544e0801fb6f658de98815ce0d8c04f58 (patch)
tree47f3143abe92b79aaa06c34ed21f5b2a198b3512 /patches/server
parent326347031287b483850190068efc3ee9994ab970 (diff)
downloadPaper-4445d23544e0801fb6f658de98815ce0d8c04f58.tar.gz
Paper-4445d23544e0801fb6f658de98815ce0d8c04f58.zip
Deprecate ItemStack#setType & add ItemStack#withType (#10290)
Diffstat (limited to 'patches/server')
-rw-r--r--patches/server/0009-MC-Utils.patch8
-rw-r--r--patches/server/0067-Handle-Item-Meta-Inconsistencies.patch8
-rw-r--r--patches/server/0193-ItemStack-getMaxItemUseDuration.patch4
-rw-r--r--patches/server/0214-PlayerElytraBoostEvent.patch4
-rw-r--r--patches/server/0221-Don-t-call-getItemMeta-on-hasItemMeta.patch4
-rw-r--r--patches/server/0716-More-Projectile-API.patch4
-rw-r--r--patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch4
-rw-r--r--patches/server/0886-fix-item-meta-for-tadpole-buckets.patch4
-rw-r--r--patches/server/0933-Allow-proper-checking-of-empty-item-stacks.patch4
-rw-r--r--patches/server/0971-Add-drops-to-shear-events.patch4
-rw-r--r--patches/server/1055-Deprecate-ItemStack-setType.patch30
-rw-r--r--patches/server/1056-Item-Mutation-Fixes.patch49
12 files changed, 105 insertions, 22 deletions
diff --git a/patches/server/0009-MC-Utils.patch b/patches/server/0009-MC-Utils.patch
index 8f3da9d5b8..40721b09a9 100644
--- a/patches/server/0009-MC-Utils.patch
+++ b/patches/server/0009-MC-Utils.patch
@@ -7892,10 +7892,10 @@ index ed501b794c222278dca98f8ece6096db1d8108a5..be3a8e54d64b3cc145ab09b0bc7abb3f
+ }
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index bf46aa3bd46ffabe92d58aa45ea0dfe6c98d94aa..23b83f8e98d681895b4e23cda4f3d50f85c12dd9 100644
+index bf46aa3bd46ffabe92d58aa45ea0dfe6c98d94aa..0bb01e53f1c15071c8cd818cce79af8196fe790f 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -23,6 +23,16 @@ import org.bukkit.material.MaterialData;
+@@ -23,6 +23,20 @@ import org.bukkit.material.MaterialData;
@DelegateDeserialization(ItemStack.class)
public final class CraftItemStack extends ItemStack {
@@ -7907,6 +7907,10 @@ index bf46aa3bd46ffabe92d58aa45ea0dfe6c98d94aa..23b83f8e98d681895b4e23cda4f3d50f
+ return asNMSCopy(bukkit);
+ }
+ }
++
++ public static net.minecraft.world.item.ItemStack getOrCloneOnMutation(ItemStack old, ItemStack newInstance) {
++ return old == newInstance ? unwrap(old) : asNMSCopy(newInstance);
++ }
+ // Paper end - MC Utils
+
public static net.minecraft.world.item.ItemStack asNMSCopy(ItemStack original) {
diff --git a/patches/server/0067-Handle-Item-Meta-Inconsistencies.patch b/patches/server/0067-Handle-Item-Meta-Inconsistencies.patch
index 9528bf1431..279fb52e31 100644
--- a/patches/server/0067-Handle-Item-Meta-Inconsistencies.patch
+++ b/patches/server/0067-Handle-Item-Meta-Inconsistencies.patch
@@ -70,10 +70,10 @@ index 6291265ae4691bf7dffe196d20571c1c30e8d906..70511628eefc28163d07f50f18d9cc55
public boolean isEnchanted() {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index 23b83f8e98d681895b4e23cda4f3d50f85c12dd9..c72a1a503f6e71228a1f82b37068ff7a83e983dc 100644
+index 0bb01e53f1c15071c8cd818cce79af8196fe790f..b59e84bbed37b002a34fe81efdce6f025617fc84 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -188,28 +188,11 @@ public final class CraftItemStack extends ItemStack {
+@@ -192,28 +192,11 @@ public final class CraftItemStack extends ItemStack {
public void addUnsafeEnchantment(Enchantment ench, int level) {
Preconditions.checkArgument(ench != null, "Enchantment cannot be null");
@@ -107,7 +107,7 @@ index 23b83f8e98d681895b4e23cda4f3d50f85c12dd9..c72a1a503f6e71228a1f82b37068ff7a
}
static boolean makeTag(net.minecraft.world.item.ItemStack item) {
-@@ -242,43 +225,15 @@ public final class CraftItemStack extends ItemStack {
+@@ -246,43 +229,15 @@ public final class CraftItemStack extends ItemStack {
public int removeEnchantment(Enchantment ench) {
Preconditions.checkArgument(ench != null, "Enchantment cannot be null");
@@ -159,7 +159,7 @@ index 23b83f8e98d681895b4e23cda4f3d50f85c12dd9..c72a1a503f6e71228a1f82b37068ff7a
return level;
}
-@@ -290,7 +245,7 @@ public final class CraftItemStack extends ItemStack {
+@@ -294,7 +249,7 @@ public final class CraftItemStack extends ItemStack {
@Override
public Map<Enchantment, Integer> getEnchantments() {
diff --git a/patches/server/0193-ItemStack-getMaxItemUseDuration.patch b/patches/server/0193-ItemStack-getMaxItemUseDuration.patch
index 83ab07155e..e66ff94efb 100644
--- a/patches/server/0193-ItemStack-getMaxItemUseDuration.patch
+++ b/patches/server/0193-ItemStack-getMaxItemUseDuration.patch
@@ -6,10 +6,10 @@ Subject: [PATCH] ItemStack#getMaxItemUseDuration
Allows you to determine how long it takes to use a usable/consumable item
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index c72a1a503f6e71228a1f82b37068ff7a83e983dc..d9a07829d5d0ebcb18b8e3f12622ed7795955d61 100644
+index b59e84bbed37b002a34fe81efdce6f025617fc84..78f2159285e676b877f85df604889ddcf19e8923 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -184,6 +184,13 @@ public final class CraftItemStack extends ItemStack {
+@@ -188,6 +188,13 @@ public final class CraftItemStack extends ItemStack {
return (this.handle == null) ? Material.AIR.getMaxStackSize() : this.handle.getItem().getMaxStackSize();
}
diff --git a/patches/server/0214-PlayerElytraBoostEvent.patch b/patches/server/0214-PlayerElytraBoostEvent.patch
index b9afdb2bf1..80552e3b6d 100644
--- a/patches/server/0214-PlayerElytraBoostEvent.patch
+++ b/patches/server/0214-PlayerElytraBoostEvent.patch
@@ -5,7 +5,7 @@ Subject: [PATCH] PlayerElytraBoostEvent
diff --git a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
-index 3749cfca8f007973d1a2206d8f2ba15283a550e1..eb655eb01e4841ca163666f21dae00f0632a11e5 100644
+index 7c627d27300247db9122ab2081049345ef306073..4565cf51ee2f973b368a984436c02220ed9f4a70 100644
--- a/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
+++ b/src/main/java/net/minecraft/world/item/FireworkRocketItem.java
@@ -68,12 +68,19 @@ public class FireworkRocketItem extends Item {
@@ -15,7 +15,7 @@ index 3749cfca8f007973d1a2206d8f2ba15283a550e1..eb655eb01e4841ca163666f21dae00f0
- world.addFreshEntity(fireworkRocketEntity);
- if (!user.getAbilities().instabuild) {
+ // Paper start - PlayerElytraBoostEvent
-+ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity());
++ com.destroystokyo.paper.event.player.PlayerElytraBoostEvent event = new com.destroystokyo.paper.event.player.PlayerElytraBoostEvent((org.bukkit.entity.Player) user.getBukkitEntity(), org.bukkit.craftbukkit.inventory.CraftItemStack.asCraftMirror(itemStack), (org.bukkit.entity.Firework) fireworkRocketEntity.getBukkitEntity(), org.bukkit.craftbukkit.CraftEquipmentSlot.getHand(hand));
+ if (event.callEvent() && world.addFreshEntity(fireworkRocketEntity)) {
+ user.awardStat(Stats.ITEM_USED.get(this));
+ if (event.shouldConsume() && !user.getAbilities().instabuild) {
diff --git a/patches/server/0221-Don-t-call-getItemMeta-on-hasItemMeta.patch b/patches/server/0221-Don-t-call-getItemMeta-on-hasItemMeta.patch
index c597f5c121..939529febe 100644
--- a/patches/server/0221-Don-t-call-getItemMeta-on-hasItemMeta.patch
+++ b/patches/server/0221-Don-t-call-getItemMeta-on-hasItemMeta.patch
@@ -11,10 +11,10 @@ Returns true if getDamage() == 0 or has damage tag or other tag is set.
Check the `ItemMetaTest#testTaggedButNotMeta` method to see how this method behaves.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index d9a07829d5d0ebcb18b8e3f12622ed7795955d61..7ce48473222516aefda3c5ad40e5e3fd23502e3d 100644
+index 78f2159285e676b877f85df604889ddcf19e8923..f3195b37c314a1327752ece7ec33dfdae16f0bec 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -675,7 +675,7 @@ public final class CraftItemStack extends ItemStack {
+@@ -679,7 +679,7 @@ public final class CraftItemStack extends ItemStack {
@Override
public boolean hasItemMeta() {
diff --git a/patches/server/0716-More-Projectile-API.patch b/patches/server/0716-More-Projectile-API.patch
index 797924f9aa..abcfbb28e9 100644
--- a/patches/server/0716-More-Projectile-API.patch
+++ b/patches/server/0716-More-Projectile-API.patch
@@ -568,10 +568,10 @@ index 7d72ccdd82daa6afe85859f5bc6ec7b187622384..fb0426a1d864f3c60637e394e5bedb39
}
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index 7ce48473222516aefda3c5ad40e5e3fd23502e3d..6725c0824b986885c8aade846f6e159986ffbe59 100644
+index f3195b37c314a1327752ece7ec33dfdae16f0bec..6b75314023adf313937990e31323dff9bacc564b 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -294,12 +294,20 @@ public final class CraftItemStack extends ItemStack {
+@@ -298,12 +298,20 @@ public final class CraftItemStack extends ItemStack {
public ItemMeta getItemMeta() {
return CraftItemStack.getItemMeta(this.handle);
}
diff --git a/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch b/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
index 8d4f6df398..0e54130972 100644
--- a/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
+++ b/patches/server/0840-Remove-CraftItemStack-setAmount-null-assignment.patch
@@ -16,10 +16,10 @@ 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
+index 6b75314023adf313937990e31323dff9bacc564b..fb2e4881096459eff16a7c46faa9921166837ee9 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 {
+@@ -161,7 +161,7 @@ public final class CraftItemStack extends ItemStack {
}
this.handle.setCount(amount);
diff --git a/patches/server/0886-fix-item-meta-for-tadpole-buckets.patch b/patches/server/0886-fix-item-meta-for-tadpole-buckets.patch
index 7dc82282e5..7ee950152d 100644
--- a/patches/server/0886-fix-item-meta-for-tadpole-buckets.patch
+++ b/patches/server/0886-fix-item-meta-for-tadpole-buckets.patch
@@ -17,10 +17,10 @@ index c421649a0c88ee9c773bb6985f7114e58f08a7a1..71aac5d4cf29cea9daa378fc8ac58475
case GLOW_ITEM_FRAME:
case PAINTING:
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index 312e756843f62371048a4d8de9deb024bd9846a7..a2e605bc1418dc0b5570566a6e348df03c9aee4c 100644
+index fb2e4881096459eff16a7c46faa9921166837ee9..f106db3aa5e5b3b0b8133eff77dbc65c8895ff2e 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -597,6 +597,7 @@ public final class CraftItemStack extends ItemStack {
+@@ -601,6 +601,7 @@ public final class CraftItemStack extends ItemStack {
case COD_BUCKET:
case PUFFERFISH_BUCKET:
case SALMON_BUCKET:
diff --git a/patches/server/0933-Allow-proper-checking-of-empty-item-stacks.patch b/patches/server/0933-Allow-proper-checking-of-empty-item-stacks.patch
index eefdaefa4b..1ffc2241c3 100644
--- a/patches/server/0933-Allow-proper-checking-of-empty-item-stacks.patch
+++ b/patches/server/0933-Allow-proper-checking-of-empty-item-stacks.patch
@@ -5,10 +5,10 @@ Subject: [PATCH] Allow proper checking of empty item stacks
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index a2e605bc1418dc0b5570566a6e348df03c9aee4c..e1f9a603e7adf3468faa9bb6d93dd3339327b47e 100644
+index f106db3aa5e5b3b0b8133eff77dbc65c8895ff2e..38ceeca108c258852eeb7a48015010a689ac43ec 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -33,12 +33,19 @@ public final class CraftItemStack extends ItemStack {
+@@ -37,12 +37,19 @@ public final class CraftItemStack extends ItemStack {
}
// Paper end - MC Utils
diff --git a/patches/server/0971-Add-drops-to-shear-events.patch b/patches/server/0971-Add-drops-to-shear-events.patch
index 3d83041ef9..a249a70023 100644
--- a/patches/server/0971-Add-drops-to-shear-events.patch
+++ b/patches/server/0971-Add-drops-to-shear-events.patch
@@ -264,10 +264,10 @@ index 99292a908b36e3c75d51c6877c7a0c01d9671aa6..0a041d0e56dfe1319e5174cb0e6085dc
public static Cancellable handleStatisticsIncrease(net.minecraft.world.entity.player.Player entityHuman, net.minecraft.stats.Stat<?> statistic, int current, int newValue) {
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-index e1f9a603e7adf3468faa9bb6d93dd3339327b47e..870954fc59efdc1e0c6b5047f5a89dfaf7522d0e 100644
+index 38ceeca108c258852eeb7a48015010a689ac43ec..f67b048c3831fcab24acd12249cbd32d386c3ffe 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
-@@ -62,6 +62,16 @@ public final class CraftItemStack extends ItemStack {
+@@ -66,6 +66,16 @@ public final class CraftItemStack extends ItemStack {
return stack;
}
diff --git a/patches/server/1055-Deprecate-ItemStack-setType.patch b/patches/server/1055-Deprecate-ItemStack-setType.patch
new file mode 100644
index 0000000000..72d51180a3
--- /dev/null
+++ b/patches/server/1055-Deprecate-ItemStack-setType.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Owen1212055 <[email protected]>
+Date: Tue, 26 Mar 2024 21:42:23 -0400
+Subject: [PATCH] Deprecate ItemStack#setType
+
+
+diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+index f67b048c3831fcab24acd12249cbd32d386c3ffe..534d3f02ad14ac246ef947a118c07cca81d600dc 100644
+--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
++++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+@@ -711,4 +711,19 @@ public final class CraftItemStack extends ItemStack {
+ static boolean hasItemMeta(net.minecraft.world.item.ItemStack item) {
+ return !(item == null || item.getTag() == null || item.getTag().isEmpty());
+ }
++ // Paper start - with type
++ @Override
++ public ItemStack withType(final Material type) {
++ if (type == Material.AIR) return CraftItemStack.asCraftMirror(null);
++
++ final net.minecraft.world.item.ItemStack copy = new net.minecraft.world.item.ItemStack(
++ CraftItemType.bukkitToMinecraft(type), this.getAmount()
++ );
++ if (this.handle != null && this.handle.getTag() != null) copy.setTag(this.handle.getTag().copy());
++
++ final CraftItemStack mirrored = CraftItemStack.asCraftMirror(copy);
++ mirrored.setItemMeta(mirrored.getItemMeta());
++ return mirrored;
++ }
++ // Paper end
+ }
diff --git a/patches/server/1056-Item-Mutation-Fixes.patch b/patches/server/1056-Item-Mutation-Fixes.patch
new file mode 100644
index 0000000000..4fc0800e22
--- /dev/null
+++ b/patches/server/1056-Item-Mutation-Fixes.patch
@@ -0,0 +1,49 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Owen1212055 <[email protected]>
+Date: Wed, 20 Mar 2024 20:41:35 -0400
+Subject: [PATCH] Item Mutation Fixes
+
+
+diff --git a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
+index 343f44db579839eb61376f876b5eff2e615dc2e5..e6935b6632c7a7e07f4da459c95f564356242f98 100644
+--- a/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
++++ b/src/main/java/net/minecraft/world/inventory/EnchantmentMenu.java
+@@ -229,7 +229,7 @@ public class EnchantmentMenu extends AbstractContainerMenu {
+ return false;
+ } else if (this.costs[id] > 0 && !itemstack.isEmpty() && (player.experienceLevel >= j && player.experienceLevel >= this.costs[id] || player.getAbilities().instabuild)) {
+ this.access.execute((world, blockposition) -> {
+- ItemStack itemstack2 = itemstack;
++ ItemStack itemstack2 = itemstack; // Paper - diff on change
+ List<EnchantmentInstance> list = this.getEnchantmentList(itemstack, id, this.costs[id]);
+
+ // CraftBukkit start
+@@ -251,11 +251,18 @@ public class EnchantmentMenu extends AbstractContainerMenu {
+ return;
+ }
+ // CraftBukkit end
+- boolean flag = itemstack.is(Items.BOOK);
++ // Paper start
++ itemstack2 = org.bukkit.craftbukkit.inventory.CraftItemStack.getOrCloneOnMutation(item, event.getItem());
++ if (itemstack2 != itemstack) {
++ this.enchantSlots.setItem(0, itemstack2);
++ }
++ boolean flag = itemstack2.is(Items.BOOK);
++ // Paper end
+
+ if (flag) {
++ CompoundTag nbttagcompound = itemstack2.getTag(); // Paper - move up
+ itemstack2 = new ItemStack(Items.ENCHANTED_BOOK);
+- CompoundTag nbttagcompound = itemstack.getTag();
++ // Paper - move up
+
+ if (nbttagcompound != null) {
+ itemstack2.setTag(nbttagcompound.copy());
+@@ -277,7 +284,7 @@ public class EnchantmentMenu extends AbstractContainerMenu {
+ EnchantmentInstance weightedrandomenchant = new EnchantmentInstance(nms, entry.getValue());
+ EnchantedBookItem.addEnchantment(itemstack2, weightedrandomenchant);
+ } else {
+- item.addUnsafeEnchantment(entry.getKey(), entry.getValue());
++ CraftItemStack.asCraftMirror(itemstack2).addUnsafeEnchantment(entry.getKey(), entry.getValue()); // Paper
+ }
+ } catch (IllegalArgumentException e) {
+ /* Just swallow invalid enchantments */