Java Code Examples for com.github.steveice10.opennbt.tag.builtin.Tag

The following examples show how to use com.github.steveice10.opennbt.tag.builtin.Tag. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: Geyser   Author: GeyserMC   File: BookPagesTranslator.java    License: MIT License 6 votes vote down vote up
@Override
public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) {
    if (!itemTag.contains("pages")) {
        return;
    }
    List<Tag> pages = new ArrayList<>();
    ListTag pagesTag = itemTag.get("pages");
    for (Tag tag : pagesTag.getValue()) {
        if (!(tag instanceof StringTag))
            continue;

        StringTag textTag = (StringTag) tag;

        CompoundTag pageTag = new CompoundTag("");
        pageTag.put(new StringTag("photoname", ""));
        pageTag.put(new StringTag("text", MessageUtils.getBedrockMessageLenient(textTag.getValue())));
        pages.add(pageTag);
    }

    itemTag.remove("pages");
    itemTag.put(new ListTag("pages", pages));
}
 
Example #2
Source Project: Geyser   Author: GeyserMC   File: BookPagesTranslator.java    License: MIT License 6 votes vote down vote up
@Override
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
    if (!itemTag.contains("pages")) {
        return;
    }
    List<Tag> pages = new ArrayList<>();
    ListTag pagesTag = itemTag.get("pages");
    for (Tag tag : pagesTag.getValue()) {
        if (!(tag instanceof CompoundTag))
            continue;

        CompoundTag pageTag = (CompoundTag) tag;

        StringTag textTag = pageTag.get("text");
        pages.add(new StringTag(MessageUtils.getJavaMessage(textTag.getValue())));
    }

    itemTag.remove("pages");
    itemTag.put(new ListTag("pages", pages));
}
 
Example #3
Source Project: Geyser   Author: GeyserMC   File: BasicItemTranslator.java    License: MIT License 6 votes vote down vote up
@Override
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
    if (!itemTag.contains("display")) {
        return;
    }
    CompoundTag displayTag = itemTag.get("display");
    if (displayTag.contains("Name")) {
        StringTag nameTag = displayTag.get("Name");
        displayTag.put(new StringTag("Name", toJavaMessage(nameTag)));
    }

    if (displayTag.contains("Lore")) {
        ListTag loreTag = displayTag.get("Lore");
        List<Tag> lore = new ArrayList<>();
        for (Tag tag : loreTag.getValue()) {
            if (!(tag instanceof StringTag)) return;
            lore.add(new StringTag("", "§r" + toJavaMessage((StringTag) tag)));
        }
        displayTag.put(new ListTag("Lore", lore));
    }
}
 
Example #4
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 6 votes vote down vote up
public CompoundTag compound() throws StringTagParseException {
    this.buffer.expect(Tokens.COMPOUND_BEGIN);
    final CompoundTag compoundTag = new CompoundTag("");
    while (this.buffer.hasMore()) {
        final String key = this.key();
        final Tag tag = this.tag();
        // Doesn't get around this with the steveice lib :/
        try {
            if (!NAME_FIELD.isAccessible()) {
                NAME_FIELD.setAccessible(true);
            }
            NAME_FIELD.set(tag, key);
        } catch (IllegalAccessException e) {
            throw new IllegalArgumentException(e);
        }

        compoundTag.put(tag);
        if (this.separatorOrCompleteWith(Tokens.COMPOUND_END)) {
            return compoundTag;
        }
    }
    throw this.buffer.makeError("Unterminated compound tag!");
}
 
Example #5
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 6 votes vote down vote up
public ListTag list() throws StringTagParseException {
    final ListTag listTag = new ListTag("");
    this.buffer.expect(Tokens.ARRAY_BEGIN);
    final boolean prefixedIndex = this.buffer.peek() == '0' && this.buffer.peek(1) == ':';
    while (this.buffer.hasMore()) {
        if (prefixedIndex) {
            this.buffer.takeUntil(':');
        }

        final Tag next = this.tag();
        // TODO: validate type
        listTag.add(next);
        if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) {
            return listTag;
        }
    }
    throw this.buffer.makeError("Reached end of file without end of list tag!");
}
 
Example #6
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 6 votes vote down vote up
/**
 * Similar to a list tag in syntax, but returning a single array tag rather than a list of tags.
 *
 * @return array-typed tag
 */
public Tag array(final char elementType) throws StringTagParseException {
    this.buffer.expect(Tokens.ARRAY_BEGIN)
            .expect(elementType)
            .expect(Tokens.ARRAY_SIGNATURE_SEPARATOR);

    if (elementType == Tokens.TYPE_BYTE) {
        return new ByteArrayTag("", this.byteArray());
    } else if (elementType == Tokens.TYPE_INT) {
        return new IntArrayTag("", this.intArray());
    } else if (elementType == Tokens.TYPE_LONG) {
        return new LongArrayTag("", this.longArray());
    } else {
        throw this.buffer.makeError("Type " + elementType + " is not a valid element type in an array!");
    }
}
 
Example #7
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 6 votes vote down vote up
public Tag tag() throws StringTagParseException {
    final char startToken = this.buffer.skipWhitespace().peek();
    switch (startToken) {
        case Tokens.COMPOUND_BEGIN:
            return this.compound();
        case Tokens.ARRAY_BEGIN:
            if (this.buffer.peek(2) == ';') { // we know we're an array tag
                return this.array(this.buffer.peek(1));
            } else {
                return this.list();
            }
        case Tokens.SINGLE_QUOTE:
        case Tokens.DOUBLE_QUOTE:
            // definitely a string tag
            this.buffer.advance();
            return new StringTag("", unescape(this.buffer.takeUntil(startToken).toString()));
        default: // scalar
            return this.scalar();
    }
}
 
Example #8
Source Project: ViaVersion   Author: ViaVersion   File: InventoryPackets.java    License: MIT License 6 votes vote down vote up
public static void toClient(Item item) {
    if (item == null) return;
    item.setIdentifier(getNewItemId(item.getIdentifier()));

    CompoundTag tag;
    if ((tag = item.getTag()) != null) {
        // Display Lore now uses JSON
        Tag displayTag = tag.get("display");
        if (displayTag instanceof CompoundTag) {
            CompoundTag display = (CompoundTag) displayTag;
            Tag loreTag = display.get("Lore");
            if (loreTag instanceof ListTag) {
                ListTag lore = (ListTag) loreTag;
                display.put(ConverterRegistry.convertToTag(NBT_TAG_NAME + "|Lore", ConverterRegistry.convertToValue(lore)));
                for (Tag loreEntry : lore) {
                    if (loreEntry instanceof StringTag) {
                        ((StringTag) loreEntry).setValue(ChatRewriter.legacyTextToJson(((StringTag) loreEntry).getValue()).toString());
                    }
                }
            }
        }
    }
}
 
Example #9
Source Project: ViaVersion   Author: ViaVersion   File: ItemRewriter.java    License: MIT License 6 votes vote down vote up
public static void rewriteBookToServer(Item item) {
    int id = item.getIdentifier();
    if (id != 387) {
        return;
    }
    CompoundTag tag = item.getTag();
    ListTag pages = tag.get("pages");
    if (pages == null) { // is this even possible?
        return;
    }
    for (int i = 0; i < pages.size(); i++) {
        Tag pageTag = pages.get(i);
        if (!(pageTag instanceof StringTag)) {
            continue;
        }
        StringTag stag = (StringTag) pageTag;
        String value = stag.getValue();
        if (value.replaceAll(" ", "").isEmpty()) {
            value = "\"" + fixBookSpaceChars(value) + "\"";
        } else {
            value = fixBookSpaceChars(value);
        }
        stag.setValue(value);
    }
}
 
Example #10
Source Project: ViaVersion   Author: ViaVersion   File: InventoryPackets.java    License: MIT License 6 votes vote down vote up
public static void toClient(Item item) {
    if (item == null) return;

    if (item.getIdentifier() == 771 && item.getTag() != null) {
        CompoundTag tag = item.getTag();
        Tag ownerTag = tag.get("SkullOwner");
        if (ownerTag instanceof CompoundTag) {
            CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
            Tag idTag = ownerCompundTag.get("Id");
            if (idTag instanceof StringTag) {
                UUID id = UUID.fromString((String) idTag.getValue());
                ownerCompundTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(id)));
            }
        }
    }

    item.setIdentifier(getNewItemId(item.getIdentifier()));
}
 
Example #11
Source Project: ViaVersion   Author: ViaVersion   File: InventoryPackets.java    License: MIT License 6 votes vote down vote up
public static void toServer(Item item) {
    if (item == null) return;

    item.setIdentifier(getOldItemId(item.getIdentifier()));

    if (item.getIdentifier() == 771 && item.getTag() != null) {
        CompoundTag tag = item.getTag();
        Tag ownerTag = tag.get("SkullOwner");
        if (ownerTag instanceof CompoundTag) {
            CompoundTag ownerCompundTag = (CompoundTag) ownerTag;
            Tag idTag = ownerCompundTag.get("Id");
            if (idTag instanceof IntArrayTag) {
                UUID id = UUIDIntArrayType.uuidFromIntArray((int[]) idTag.getValue());
                ownerCompundTag.put(new StringTag("Id", id.toString()));
            }
        }
    }
}
 
Example #12
Source Project: ViaVersion   Author: ViaVersion   File: SkullHandler.java    License: MIT License 6 votes vote down vote up
@Override
public int transform(UserConnection user, CompoundTag tag) {
    BlockStorage storage = user.get(BlockStorage.class);
    Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));

    if (!storage.contains(position)) {
        Via.getPlatform().getLogger().warning("Received an head update packet, but there is no head! O_o " + tag);
        return -1;
    }

    int id = storage.get(position).getOriginal();
    if (id >= SKULL_WALL_START && id <= SKULL_END) {
        Tag skullType = tag.get("SkullType");
        if (skullType != null) {
            id += ((Number) tag.get("SkullType").getValue()).intValue() * 20;
        }
        if (tag.contains("Rot")) {
            id += ((Number) tag.get("Rot").getValue()).intValue();
        }
    } else {
        Via.getPlatform().getLogger().warning("Why does this block have the skull block entity? " + tag);
        return -1;
    }

    return id;
}
 
Example #13
Source Project: ViaVersion   Author: ViaVersion   File: BedHandler.java    License: MIT License 6 votes vote down vote up
@Override
public int transform(UserConnection user, CompoundTag tag) {
    BlockStorage storage = user.get(BlockStorage.class);
    Position position = new Position((int) getLong(tag.get("x")), (short) getLong(tag.get("y")), (int) getLong(tag.get("z")));

    if (!storage.contains(position)) {
        Via.getPlatform().getLogger().warning("Received an bed color update packet, but there is no bed! O_o " + tag);
        return -1;
    }

    //                                              RED_BED + FIRST_BED
    int blockId = storage.get(position).getOriginal() - 972 + 748;

    Tag color = tag.get("color");
    if (color != null) {
        blockId += (((Number) color.getValue()).intValue() * 16);
    }

    return blockId;
}
 
Example #14
Source Project: ViaVersion   Author: ViaVersion   File: BlockEntityProvider.java    License: MIT License 6 votes vote down vote up
/**
 * Transforms the BlockEntities to blocks!
 *
 * @param user       UserConnection instance
 * @param position   Block Position - WARNING: Position is null when called from a chunk
 * @param tag        BlockEntity NBT
 * @param sendUpdate send a block change update
 * @return new block id
 * @throws Exception Gotta throw that exception
 */
public int transform(UserConnection user, Position position, CompoundTag tag, boolean sendUpdate) throws Exception {
    Tag idTag = tag.get("id");
    if (idTag == null) return -1;

    String id = (String) idTag.getValue();
    BlockEntityHandler handler = handlers.get(id);
    if (handler == null) {
        if (Via.getManager().isDebug()) {
            Via.getPlatform().getLogger().warning("Unhandled BlockEntity " + id + " full tag: " + tag);
        }
        return -1;
    }

    int newBlock = handler.transform(user, tag);

    if (sendUpdate && newBlock != -1) {
        sendBlockChange(user, position, newBlock);
    }

    return newBlock;
}
 
Example #15
Source Project: Geyser   Author: GeyserMC   File: EnchantedBookTranslator.java    License: MIT License 5 votes vote down vote up
@Override
public void translateToBedrock(CompoundTag itemTag, ItemEntry itemEntry) {
    if (!itemTag.contains("StoredEnchantments")) {
        return;
    }
    Tag enchTag = itemTag.get("StoredEnchantments");
    if (enchTag instanceof ListTag) {
        enchTag = new ListTag("Enchantments", ((ListTag) enchTag).getValue());
        itemTag.remove("StoredEnchantments");
        itemTag.put(enchTag);
    }
}
 
Example #16
Source Project: Geyser   Author: GeyserMC   File: EnchantedBookTranslator.java    License: MIT License 5 votes vote down vote up
@Override
public void translateToJava(CompoundTag itemTag, ItemEntry itemEntry) {
    if (!itemTag.contains("Enchantments")) {
        return;
    }
    Tag enchTag = itemTag.get("Enchantments");
    if (enchTag instanceof ListTag) {
        enchTag = new ListTag("StoredEnchantments", ((ListTag) enchTag).getValue());
        itemTag.remove("Enchantments");
        itemTag.put(enchTag);
    }
}
 
Example #17
Source Project: Geyser   Author: GeyserMC   File: BannerTranslator.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a list of patterns from Java nbt to Bedrock nbt
 *
 * @param patterns The patterns to convert
 * @return The new converted patterns
 */
public static com.nukkitx.nbt.tag.ListTag convertBannerPattern(ListTag patterns) {
    List<com.nukkitx.nbt.tag.CompoundTag> tagsList = new ArrayList<>();
    for (com.github.steveice10.opennbt.tag.builtin.Tag patternTag : patterns.getValue()) {
        com.nukkitx.nbt.tag.CompoundTag newPatternTag = getBedrockBannerPattern((CompoundTag) patternTag);
        if (newPatternTag != null) {
            tagsList.add(newPatternTag);
        }
    }

    return new com.nukkitx.nbt.tag.ListTag<>("Patterns", com.nukkitx.nbt.tag.CompoundTag.class, tagsList);
}
 
Example #18
Source Project: Geyser   Author: GeyserMC   File: BannerTranslator.java    License: MIT License 5 votes vote down vote up
/**
 * Convert a list of patterns from Bedrock nbt to Java nbt
 *
 * @param patterns The patterns to convert
 * @return The new converted patterns
 */
public static ListTag convertBannerPattern(com.nukkitx.nbt.tag.ListTag<?> patterns) {
    List<Tag> tagsList = new ArrayList<>();
    for (Object patternTag : patterns.getValue()) {
        CompoundTag newPatternTag = getJavaBannerPattern((com.nukkitx.nbt.tag.CompoundTag) patternTag);
        tagsList.add(newPatternTag);
    }

    return new ListTag("Patterns", tagsList);
}
 
Example #19
Source Project: Geyser   Author: GeyserMC   File: BannerTranslator.java    License: MIT License 5 votes vote down vote up
/**
 * Convert the Bedrock edition banner pattern nbt to Java edition
 *
 * @param pattern Bedorck edition pattern nbt
 * @return The Java edition format pattern nbt
 */
public static CompoundTag getJavaBannerPattern(com.nukkitx.nbt.tag.CompoundTag pattern) {
    Map<String, Tag> tags = new HashMap<>();
    tags.put("Color", new IntTag("Color", 15 - pattern.getInt("Color")));
    tags.put("Pattern", new StringTag("Pattern", pattern.getString("Pattern")));

    return new CompoundTag("", tags);
}
 
Example #20
Source Project: Geyser   Author: GeyserMC   File: PotionTranslator.java    License: MIT License 5 votes vote down vote up
@Override
public ItemData translateToBedrock(ItemStack itemStack, ItemEntry itemEntry) {
    if (itemStack.getNbt() == null) return super.translateToBedrock(itemStack, itemEntry);
    Tag potionTag = itemStack.getNbt().get("Potion");
    if (potionTag instanceof StringTag) {
        Potion potion = Potion.getByJavaIdentifier(((StringTag) potionTag).getValue());
        if (potion != null) {
            return ItemData.of(itemEntry.getBedrockId(), potion.getBedrockId(), itemStack.getAmount(), translateNbtToBedrock(itemStack.getNbt()));
        }
        GeyserConnector.getInstance().getLogger().debug("Unknown java potion: " + potionTag.getValue());
    }
    return super.translateToBedrock(itemStack, itemEntry);
}
 
Example #21
Source Project: Cleanstone   Author: CleanstoneMC   File: UpdateTradePacket.java    License: MIT License 5 votes vote down vote up
public UpdateTradePacket(byte windowID, byte windowType, int unknown0, int unknown1, boolean isWilling, long traderEntityID, long playerEntityID, String displayName, Tag namedTag) {
    this.windowID = windowID;
    this.windowType = windowType;
    this.unknown0 = unknown0;
    this.unknown1 = unknown1;
    this.isWilling = isWilling;
    this.traderEntityID = traderEntityID;
    this.playerEntityID = playerEntityID;
    this.displayName = displayName;
    this.namedTag = namedTag;
}
 
Example #22
Source Project: Cleanstone   Author: CleanstoneMC   File: UpdateEquipmentPacket.java    License: MIT License 5 votes vote down vote up
public UpdateEquipmentPacket(byte windowID, byte windowType, byte unknown, long entityID, Tag namedTag) {
    this.windowID = windowID;
    this.windowType = windowType;
    this.unknown = unknown;
    this.entityID = entityID;
    this.namedTag = namedTag;
}
 
Example #23
Source Project: Cleanstone   Author: CleanstoneMC   File: ChunkDataPacket.java    License: MIT License 5 votes vote down vote up
public ChunkDataPacket(int chunkX, int chunkZ, boolean groundUpContinuous,
                       BlockDataStorage blockDataStorage, Tag blockEntities) {
    this.chunkX = chunkX;
    this.chunkZ = chunkZ;
    this.groundUpContinuous = groundUpContinuous;
    this.blockDataStorage = blockDataStorage;
    this.blockEntities = blockEntities;
}
 
Example #24
Source Project: ViaVersion   Author: ViaVersion   File: TagStringWriter.java    License: MIT License 5 votes vote down vote up
public TagStringWriter writeTag(final Tag tag) throws IOException {
    if (tag instanceof CompoundTag) {
        return this.writeCompound((CompoundTag) tag);
    } else if (tag instanceof ListTag) {
        return this.writeList((ListTag) tag);
    } else if (tag instanceof ByteArrayTag) {
        return this.writeByteArray((ByteArrayTag) tag);
    } else if (tag instanceof IntArrayTag) {
        return this.writeIntArray((IntArrayTag) tag);
    } else if (tag instanceof LongArrayTag) {
        return this.writeLongArray((LongArrayTag) tag);
    } else if (tag instanceof StringTag) {
        return this.value(((StringTag) tag).getValue(), Tokens.EOF);
    } else if (tag instanceof ByteTag) {
        return this.value(Byte.toString(((ByteTag) tag).getValue()), Tokens.TYPE_BYTE);
    } else if (tag instanceof ShortTag) {
        return this.value(Short.toString(((ShortTag) tag).getValue()), Tokens.TYPE_SHORT);
    } else if (tag instanceof IntTag) {
        return this.value(Integer.toString(((IntTag) tag).getValue()), Tokens.TYPE_INT);
    } else if (tag instanceof LongTag) {
        return this.value(Long.toString(((LongTag) tag).getValue()), Tokens.TYPE_LONG);
    } else if (tag instanceof FloatTag) {
        return this.value(Float.toString(((FloatTag) tag).getValue()), Tokens.TYPE_FLOAT);
    } else if (tag instanceof DoubleTag) {
        return this.value(Double.toString(((DoubleTag) tag).getValue()), Tokens.TYPE_DOUBLE);
    } else {
        throw new IOException("Unknown tag type: " + tag.getClass().getSimpleName());
        // unknown!
    }
}
 
Example #25
Source Project: ViaVersion   Author: ViaVersion   File: TagStringWriter.java    License: MIT License 5 votes vote down vote up
private TagStringWriter writeCompound(final CompoundTag tag) throws IOException {
    this.beginCompound();
    for (Tag t : tag) {
        this.key(t.getName());
        this.writeTag(t);
    }
    this.endCompound();
    return this;
}
 
Example #26
Source Project: ViaVersion   Author: ViaVersion   File: TagStringWriter.java    License: MIT License 5 votes vote down vote up
private TagStringWriter writeList(final ListTag tag) throws IOException {
    this.beginList();
    for (final Tag el : tag) {
        this.printAndResetSeparator();
        this.writeTag(el);
    }
    this.endList();
    return this;
}
 
Example #27
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 5 votes vote down vote up
private static Field getNameField() {
    try {
        return Tag.class.getDeclaredField("name");
    } catch (NoSuchFieldException e) {
        e.printStackTrace();
        throw new IllegalArgumentException(e);
    }
}
 
Example #28
Source Project: ViaVersion   Author: ViaVersion   File: TagStringReader.java    License: MIT License 5 votes vote down vote up
private int[] intArray() throws StringTagParseException {
    final IntStream.Builder builder = IntStream.builder();
    while (this.buffer.hasMore()) {
        final Tag value = this.tag();
        if (!(value instanceof IntTag)) {
            throw this.buffer.makeError("All elements of an int array must be ints!");
        }
        builder.add(((IntTag) value).getValue());
        if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) {
            return builder.build().toArray();
        }
    }
    throw this.buffer.makeError("Reached end of document without array close");
}
 
Example #29
Source Project: ViaVersion   Author: ViaVersion   File: InventoryPackets.java    License: MIT License 5 votes vote down vote up
public static void toServer(Item item) {
    if (item == null) return;
    item.setIdentifier(getOldItemId(item.getIdentifier()));

    CompoundTag tag;
    if ((tag = item.getTag()) != null) {
        // Display Name now uses JSON
        Tag displayTag = tag.get("display");
        if (displayTag instanceof CompoundTag) {
            CompoundTag display = (CompoundTag) displayTag;
            Tag loreTag = display.get("Lore");
            if (loreTag instanceof ListTag) {
                ListTag lore = (ListTag) loreTag;
                ListTag via = display.get(NBT_TAG_NAME + "|Lore");
                if (via != null) {
                    display.put(ConverterRegistry.convertToTag("Lore", ConverterRegistry.convertToValue(via)));
                } else {
                    for (Tag loreEntry : lore) {
                        if (loreEntry instanceof StringTag) {
                            ((StringTag) loreEntry).setValue(
                                    ChatRewriter.jsonTextToLegacy(
                                            ((StringTag) loreEntry).getValue()
                                    )
                            );
                        }
                    }
                }
                display.remove(NBT_TAG_NAME + "|Lore");
            }
        }
    }
}
 
Example #30
Source Project: ViaVersion   Author: ViaVersion   File: WorldPackets.java    License: MIT License 5 votes vote down vote up
private static void handleBlockEntity(CompoundTag compoundTag) {
    StringTag idTag = compoundTag.get("id");
    if (idTag == null) return;

    String id = idTag.getValue();
    if (id.equals("minecraft:conduit")) {
        Tag targetUuidTag = compoundTag.remove("target_uuid");
        if (!(targetUuidTag instanceof StringTag)) return;

        // target_uuid -> Target
        UUID targetUuid = UUID.fromString((String) targetUuidTag.getValue());
        compoundTag.put(new IntArrayTag("Target", UUIDIntArrayType.uuidToIntArray(targetUuid)));
    } else if (id.equals("minecraft:skull") && compoundTag.get("Owner") instanceof CompoundTag) {
        CompoundTag ownerTag = compoundTag.remove("Owner");
        StringTag ownerUuidTag = ownerTag.remove("Id");
        if (ownerUuidTag != null) {
            UUID ownerUuid = UUID.fromString(ownerUuidTag.getValue());
            ownerTag.put(new IntArrayTag("Id", UUIDIntArrayType.uuidToIntArray(ownerUuid)));
        }

        // Owner -> SkullOwner
        CompoundTag skullOwnerTag = new CompoundTag("SkullOwner");
        for (Tag tag : ownerTag) {
            skullOwnerTag.put(tag);
        }
        compoundTag.put(skullOwnerTag);
    }
}