mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-14 20:31:37 +01:00
Deprecate ItemStack#setType
This commit is contained in:
parent
66ebf93c21
commit
70cd7cfb23
@ -429,4 +429,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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user