Skip to content

Commit 6c244a4

Browse files
Update to 1.21.6
1 parent e2f0dbe commit 6c244a4

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[versions]
22
kotlin = "2.1.0"
3-
paper = "1.21.5-R0.1-SNAPSHOT"
3+
paper = "1.21.6-R0.1-SNAPSHOT"
44

55
[libraries]
66
commons-provider = { module = "xyz.xenondevs.commons:commons-provider", version = "2.0.0-alpha.2" }

invui/src/main/java/xyz/xenondevs/invui/internal/util/DataUtils.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,13 @@ public static byte[][] read2DByteArray(DataInputStream din) throws IOException {
4040
*/
4141
public static void serializeItemStack(ItemStack itemStack, OutputStream out) {
4242
try {
43-
var tag = CraftItemStack.unwrap(itemStack).save(MinecraftServer.getServer().registryAccess());
44-
NbtIo.write((CompoundTag) tag, new DataOutputStream(out));
43+
var tag = (CompoundTag) net.minecraft.world.item.ItemStack.CODEC.encodeStart(
44+
MinecraftServer.getServer()
45+
.registryAccess()
46+
.createSerializationContext(NbtOps.INSTANCE),
47+
CraftItemStack.unwrap(itemStack)
48+
).getOrThrow();
49+
NbtIo.write(tag, new DataOutputStream(out));
4550
} catch (IOException e) {
4651
throw new RuntimeException(e);
4752
}
@@ -63,9 +68,12 @@ public static ItemStack deserializeItemStack(int dataVersion, InputStream in) {
6368
dataVersion, CraftMagicNumbers.INSTANCE.getDataVersion()
6469
).getValue();
6570

66-
return net.minecraft.world.item.ItemStack.parse(MinecraftServer.getServer().registryAccess(), tag)
67-
.orElseThrow()
68-
.asBukkitMirror();
71+
return net.minecraft.world.item.ItemStack.CODEC.parse(
72+
MinecraftServer.getServer()
73+
.registryAccess()
74+
.createSerializationContext(NbtOps.INSTANCE),
75+
tag
76+
).resultOrPartial().orElseThrow().asBukkitMirror();
6977
} catch (IOException e) {
7078
throw new RuntimeException(e);
7179
}

0 commit comments

Comments
 (0)