2024-04-12 23:16:22 +02:00
|
|
|
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-07-18 10:13:20 +02:00
|
|
|
index a1a32a77bda0560a7b7f30a5d1c1837ee96997d3..9be7859ccb5283b2040ba68d72d6dbdafb4d6835 100644
|
2024-04-12 23:16:22 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
|
2024-07-18 10:13:20 +02:00
|
|
|
@@ -417,4 +417,24 @@ public final class CraftItemStack extends ItemStack {
|
2024-04-12 23:16:22 +02:00
|
|
|
static boolean hasItemMeta(net.minecraft.world.item.ItemStack item) {
|
2024-04-25 02:36:24 +02:00
|
|
|
return !(item == null || item.getComponentsPatch().isEmpty());
|
2024-04-12 23:16:22 +02:00
|
|
|
}
|
|
|
|
+ // 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);
|
|
|
|
+ }
|
2024-04-12 23:16:22 +02:00
|
|
|
+
|
|
|
|
+ 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) {
|
2024-04-28 02:33:17 +02:00
|
|
|
+ copy.applyComponents(this.handle.getComponentsPatch());
|
2024-04-25 22:34:46 +02:00
|
|
|
+ }
|
2024-04-12 23:16:22 +02:00
|
|
|
+
|
|
|
|
+ final CraftItemStack mirrored = CraftItemStack.asCraftMirror(copy);
|
|
|
|
+ mirrored.setItemMeta(mirrored.getItemMeta());
|
|
|
|
+ return mirrored;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
}
|