Search in sources :

Example 51 with TagCompound

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

the class MyStray 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)

Example 52 with TagCompound

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

the class MyTraderLlama method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    info.getCompoundData().put("Variant", new TagInt(getVariant()));
    info.getCompoundData().put("Baby", new TagByte(isBaby()));
    if (hasChest()) {
        info.getCompoundData().put("Chest", MyPetApi.getPlatformHelper().itemStackToCompund(getChest()));
    }
    if (hasDecor()) {
        info.getCompoundData().put("Decor", MyPetApi.getPlatformHelper().itemStackToCompund(getDecor()));
    }
    return info;
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 53 with TagCompound

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

the class MyTurtle method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    info.getCompoundData().put("Baby", new TagByte(isBaby()));
    return info;
}
Also used : TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 54 with TagCompound

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

the class MyVillager method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    info.getCompoundData().put("Profession", new TagInt(getProfession()));
    info.getCompoundData().put("VillagerType", new TagInt(getType().ordinal()));
    info.getCompoundData().put("VillagerLevel", new TagInt(getVillagerLevel()));
    info.getCompoundData().put("Baby", new TagByte(isBaby()));
    if (originalData != null) {
        info.getCompoundData().put("OriginalData", originalData);
    }
    return info;
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 55 with TagCompound

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

the class MyStrider method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    if (hasSaddle()) {
        info.getCompoundData().put("Saddle", MyPetApi.getPlatformHelper().itemStackToCompund(getSaddle()));
    }
    info.getCompoundData().put("Baby", new TagByte(isBaby()));
    return info;
}
Also used : TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Aggregations

TagCompound (de.keyle.knbt.TagCompound)199 TagInt (de.keyle.knbt.TagInt)67 TagByte (de.keyle.knbt.TagByte)65 TagList (de.keyle.knbt.TagList)57 ItemStack (org.bukkit.inventory.ItemStack)53 ArrayList (java.util.ArrayList)27 TagString (de.keyle.knbt.TagString)24 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 CompoundTag (net.minecraft.nbt.CompoundTag)12 MyPetBaby (de.Keyle.MyPet.api.entity.MyPetBaby)11 TagShort (de.keyle.knbt.TagShort)10 HashSet (java.util.HashSet)9 MaterialData (org.bukkit.material.MaterialData)9 ListTag (net.minecraft.nbt.ListTag)8 CraftItemStack (org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack)6 CraftItemStack (org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack)6 TagBase (de.keyle.knbt.TagBase)5 List (java.util.List)5 ItemStack (net.minecraft.world.item.ItemStack)4 WorldGroup (de.Keyle.MyPet.api.WorldGroup)3