Search in sources :

Example 6 with IntArrayTag

use of net.minecraft.nbt.IntArrayTag in project MyPet by xXKeyleXx.

the class ItemStackNBTConverter method vanillaCompoundToCompound.

public static TagBase vanillaCompoundToCompound(Tag vanillaTag) {
    switch(vanillaTag.getId()) {
        case 1:
            return new TagByte(((ByteTag) vanillaTag).getAsByte());
        case 2:
            return new TagShort(((ShortTag) vanillaTag).getAsShort());
        case 3:
            return new TagInt(((IntTag) vanillaTag).getAsInt());
        case 4:
            return new TagLong(((LongTag) vanillaTag).getAsLong());
        case 5:
            return new TagFloat(((FloatTag) vanillaTag).getAsFloat());
        case 6:
            return new TagDouble(((DoubleTag) vanillaTag).getAsDouble());
        case 7:
            return new TagByteArray(((ByteArrayTag) vanillaTag).getAsByteArray());
        case 8:
            return new TagString(vanillaTag.getAsString());
        case 9:
            ListTag tagList = (ListTag) vanillaTag;
            List compoundList = new ArrayList();
            try {
                ArrayList list = (ArrayList) TAG_LIST_LIST.get(tagList);
                for (Object aList : list) {
                    compoundList.add(vanillaCompoundToCompound((Tag) aList));
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            return new TagList(compoundList);
        case 10:
            TagCompound compound = new TagCompound();
            CompoundTag tagCompound = ((CompoundTag) vanillaTag);
            Set<String> keys = tagCompound.getAllKeys();
            for (String tagName : keys) {
                compound.getCompoundData().put(tagName, vanillaCompoundToCompound(tagCompound.get(tagName)));
            }
            return compound;
        case 11:
            return new TagIntArray(((IntArrayTag) vanillaTag).getAsIntArray());
    }
    return null;
}
Also used : TagIntArray(de.keyle.knbt.TagIntArray) TagShort(de.keyle.knbt.TagShort) TagInt(de.keyle.knbt.TagInt) ArrayList(java.util.ArrayList) TagString(de.keyle.knbt.TagString) TagString(de.keyle.knbt.TagString) TagFloat(de.keyle.knbt.TagFloat) ListTag(net.minecraft.nbt.ListTag) TagCompound(de.keyle.knbt.TagCompound) TagDouble(de.keyle.knbt.TagDouble) TagByteArray(de.keyle.knbt.TagByteArray) TagLong(de.keyle.knbt.TagLong) TagList(de.keyle.knbt.TagList) ArrayList(java.util.ArrayList) TagList(de.keyle.knbt.TagList) List(java.util.List) DoubleTag(net.minecraft.nbt.DoubleTag) Tag(net.minecraft.nbt.Tag) StringTag(net.minecraft.nbt.StringTag) ByteTag(net.minecraft.nbt.ByteTag) IntTag(net.minecraft.nbt.IntTag) IntArrayTag(net.minecraft.nbt.IntArrayTag) FloatTag(net.minecraft.nbt.FloatTag) ByteArrayTag(net.minecraft.nbt.ByteArrayTag) LongTag(net.minecraft.nbt.LongTag) ShortTag(net.minecraft.nbt.ShortTag) CompoundTag(net.minecraft.nbt.CompoundTag) ListTag(net.minecraft.nbt.ListTag) TagByte(de.keyle.knbt.TagByte) CompoundTag(net.minecraft.nbt.CompoundTag)

Example 7 with IntArrayTag

use of net.minecraft.nbt.IntArrayTag in project SpongeCommon by SpongePowered.

the class PrimaryLevelDataMixin method bridge$writeSpongeLevelData.

@Override
public CompoundTag bridge$writeSpongeLevelData() {
    final CompoundTag data = new CompoundTag();
    data.putUUID(Constants.Sponge.World.UNIQUE_ID, this.bridge$uniqueId());
    // Map Storage
    final CompoundTag mapUUIDIndexTag = new CompoundTag();
    MapUtil.saveMapUUIDIndex(mapUUIDIndexTag, this.bridge$getMapUUIDIndex());
    data.put(Constants.Map.MAP_UUID_INDEX, mapUUIDIndexTag);
    final ListTag playerIdList = new ListTag();
    data.put(Constants.Sponge.SPONGE_PLAYER_UUID_TABLE, playerIdList);
    this.impl$pendingUniqueIds.forEach(uuid -> playerIdList.add(new IntArrayTag(SerializableUUID.uuidToIntArray(uuid))));
    this.impl$pendingUniqueIds.clear();
    return data;
}
Also used : IntArrayTag(net.minecraft.nbt.IntArrayTag) ListTag(net.minecraft.nbt.ListTag) CompoundTag(net.minecraft.nbt.CompoundTag)

Aggregations

CompoundTag (net.minecraft.nbt.CompoundTag)7 IntArrayTag (net.minecraft.nbt.IntArrayTag)7 ListTag (net.minecraft.nbt.ListTag)7 ByteArrayTag (net.minecraft.nbt.ByteArrayTag)6 TagCompound (de.keyle.knbt.TagCompound)4 TagList (de.keyle.knbt.TagList)4 TagString (de.keyle.knbt.TagString)4 List (java.util.List)4 ByteTag (net.minecraft.nbt.ByteTag)4 DoubleTag (net.minecraft.nbt.DoubleTag)4 FloatTag (net.minecraft.nbt.FloatTag)4 IntTag (net.minecraft.nbt.IntTag)4 LongTag (net.minecraft.nbt.LongTag)4 ShortTag (net.minecraft.nbt.ShortTag)4 StringTag (net.minecraft.nbt.StringTag)4 Tag (net.minecraft.nbt.Tag)4 TagBase (de.keyle.knbt.TagBase)2 TagByte (de.keyle.knbt.TagByte)2 TagByteArray (de.keyle.knbt.TagByteArray)2 TagDouble (de.keyle.knbt.TagDouble)2