Paper/patches/server/0926-Deprecate-ItemStack-setType.patch

36 lines
1.5 KiB
Diff
Raw Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
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
2024-10-24 15:53:28 +02:00
index ffd7ba14be38a117f5a7d7035a8d71a20fb1c4fc..7228d43d331de16cbaa0e97c7e3fa45c0bc89558 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
2024-10-24 15:53:28 +02:00
@@ -429,4 +429,24 @@ public final class CraftItemStack extends ItemStack {
static boolean hasItemMeta(net.minecraft.world.item.ItemStack item) {
2024-04-25 02:36:24 +02:00
return !(item == null || item.getComponentsPatch().isEmpty());
}
+ // Paper start - with type
+ @Override
+ public ItemStack withType(final Material type) {
2024-04-25 22:34:46 +02:00
+ 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()
+ );
2024-04-25 22:34:46 +02:00
+
+ if (this.handle != null) {
+ copy.applyComponents(this.handle.getComponentsPatch());
2024-04-25 22:34:46 +02:00
+ }
+
+ final CraftItemStack mirrored = CraftItemStack.asCraftMirror(copy);
+ mirrored.setItemMeta(mirrored.getItemMeta());
+ return mirrored;
+ }
+ // Paper end
}