From 432977614f88da2cc20f2ec2ab73405667f77b88 Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 23 Mar 2020 11:13:38 +0100 Subject: [PATCH] Fix skull item nbt --- .../packets/BlockItemPackets1_16.java | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java index 22b0de9c..627a1337 100644 --- a/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java +++ b/core/src/main/java/nl/matsv/viabackwards/protocol/protocol1_15_2to1_16/packets/BlockItemPackets1_16.java @@ -209,6 +209,47 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It return id; } + @Override + public Item handleItemToClient(Item item) { + if (item == null) return null; + + super.handleItemToClient(item); + + if (item.getIdentifier() == 771 && item.getTag() != null) { + CompoundTag tag = item.getTag(); + CompoundTag ownerTag = tag.get("SkullOwner"); + if (ownerTag != null) { + IntArrayTag idTag = ownerTag.remove("Id"); + if (idTag != null) { + UUID ownerUuid = UUIDIntArrayType.uuidFromIntArray((idTag).getValue()); + ownerTag.put(new StringTag("Id", ownerUuid.toString())); + } + } + } + return item; + } + + @Override + public Item handleItemToServer(Item item) { + if (item == null) return null; + + int identifier = item.getIdentifier(); + super.handleItemToServer(item); + + if (identifier == 771 && item.getTag() != null) { + CompoundTag tag = item.getTag(); + CompoundTag ownerTag = tag.get("SkullOwner"); + if (ownerTag != null) { + StringTag idTag = ownerTag.remove("Id"); + if (idTag != null) { + UUID ownerUuid = UUID.fromString(idTag.getValue()); + ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid))); + } + } + } + return item; + } + public static int getNewItemId(int id) { Integer newId = MappingData.oldToNewItems.get(id); if (newId == null) { @@ -218,7 +259,6 @@ public class BlockItemPackets1_16 extends nl.matsv.viabackwards.api.rewriters.It return newId; } - public static int getOldItemId(int id) { Integer oldId = MappingData.oldToNewItems.inverse().get(id); if (oldId == null) {