Skip to content
This repository was archived by the owner on Nov 28, 2025. It is now read-only.

Commit d9be98b

Browse files
committed
fix item stack clone
1 parent 81ed522 commit d9be98b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/main/kotlin/io/github/dockyardmc/data/DataComponentPatch.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ class DataComponentPatch(internal val components: Int2ObjectMap<DataComponent?>,
8484
}
8585
}
8686

87+
fun clone(): DataComponentPatch {
88+
return DataComponentPatch(Int2ObjectArrayMap(components.toMap()), isPatch, isTrusted)
89+
}
90+
8791
fun isEmpty(): Boolean = components.isEmpty()
8892

8993
fun has(component: DataComponent): Boolean {

src/main/kotlin/io/github/dockyardmc/item/ItemStack.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,5 +304,5 @@ fun Collection<String>.toComponents(): Collection<Component> {
304304
}
305305

306306
fun ItemStack.clone(): ItemStack {
307-
return ItemStack(material, amount, components, existingMeta, attributes)
307+
return ItemStack(material, amount, components.clone(), existingMeta, attributes.toList())
308308
}

0 commit comments

Comments
 (0)