Search in sources :

Example 6 with TagBase

use of de.keyle.knbt.TagBase in project MyPet by xXKeyleXx.

the class MyWitherSkeleton method readExtendedInfo.

@SuppressWarnings("unchecked")
@Override
public void readExtendedInfo(TagCompound info) {
    if (info.containsKey("Equipment")) {
        TagList equipment = info.getAs("Equipment", TagList.class);
        List<TagBase> equipmentList = (List<TagBase>) equipment.getData();
        for (TagBase tag : equipmentList) {
            if (tag instanceof TagCompound) {
                TagCompound item = (TagCompound) tag;
                try {
                    ItemStack itemStack = MyPetApi.getPlatformHelper().compundToItemStack(item);
                    setEquipment(EquipmentSlot.getSlotById(item.getAs("Slot", TagInt.class).getIntData()), itemStack);
                } catch (Exception e) {
                    MyPetApi.getLogger().warning("Could not load Equipment item from pet data!");
                }
            }
        }
    }
}
Also used : TagBase(de.keyle.knbt.TagBase) TagInt(de.keyle.knbt.TagInt) TagList(de.keyle.knbt.TagList) ArrayList(java.util.ArrayList) List(java.util.List) TagList(de.keyle.knbt.TagList) ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound)

Aggregations

TagBase (de.keyle.knbt.TagBase)6 TagCompound (de.keyle.knbt.TagCompound)5 TagList (de.keyle.knbt.TagList)5 TagInt (de.keyle.knbt.TagInt)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ItemStack (org.bukkit.inventory.ItemStack)3 TagString (de.keyle.knbt.TagString)2 ByteArrayTag (net.minecraft.nbt.ByteArrayTag)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 IntArrayTag (net.minecraft.nbt.IntArrayTag)2 ListTag (net.minecraft.nbt.ListTag)2