Paper/patches/server/0942-Deprecate-ItemStack-setType.patch
Nassim Jahnke dc684c60d1
Remove bad server.scheduleOnMain disconnect calls from old patches
The new behavior of disconnect to block the current thread until the disconnect succeeded is better than throwing it off to happen at some point
2024-06-16 12:56:00 +02:00

36 lines
1.5 KiB
Diff

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
index 62b5ba0cafd3a09229648b1205679148b476edcc..ef56ebc8060da1d416d91299b03ff0a8f6901ac1 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftItemStack.java
@@ -415,4 +415,24 @@ public final class CraftItemStack extends ItemStack {
static boolean hasItemMeta(net.minecraft.world.item.ItemStack item) {
return !(item == null || item.getComponentsPatch().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) {
+ copy.applyComponents(this.handle.getComponentsPatch());
+ }
+
+ final CraftItemStack mirrored = CraftItemStack.asCraftMirror(copy);
+ mirrored.setItemMeta(mirrored.getItemMeta());
+ return mirrored;
+ }
+ // Paper end
}