Search in sources :

Example 36 with TagCompound

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

the class MyCreeper method writeExtendedInfo.

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

Example 37 with TagCompound

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

the class MyDonkey method readExtendedInfo.

@Override
public void readExtendedInfo(TagCompound info) {
    if (info.getCompoundData().containsKey("Baby")) {
        setBaby(info.getAs("Baby", TagByte.class).getBooleanData());
    }
    if (info.containsKeyAs("Chest", TagByte.class)) {
        boolean chest = info.getAs("Chest", TagByte.class).getBooleanData();
        if (chest) {
            ItemStack item = new ItemStack(Material.CHEST);
            setChest(item);
        }
    } else if (info.containsKeyAs("Chest", TagCompound.class)) {
        TagCompound itemTag = info.get("Chest");
        ItemStack item = MyPetApi.getPlatformHelper().compundToItemStack(itemTag);
        setChest(item);
    }
    if (info.containsKeyAs("Saddle", TagByte.class)) {
        boolean saddle = info.getAs("Saddle", TagByte.class).getBooleanData();
        if (saddle) {
            ItemStack item = new ItemStack(Material.SADDLE);
            setSaddle(item);
        }
    } else if (info.containsKeyAs("Saddle", TagCompound.class)) {
        TagCompound itemTag = info.get("Saddle");
        ItemStack item = MyPetApi.getPlatformHelper().compundToItemStack(itemTag);
        setSaddle(item);
    }
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 38 with TagCompound

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

the class MyEnderman method readExtendedInfo.

@Override
public void readExtendedInfo(TagCompound info) {
    if (info.getCompoundData().containsKey("BlockID")) {
        int id;
        int data = 0;
        if (info.containsKeyAs("BlockID", TagShort.class)) {
            id = info.getAs("BlockID", TagShort.class).getShortData();
        } else {
            id = info.getAs("BlockID", TagInt.class).getIntData();
        }
        if (info.containsKeyAs("BlockData", TagShort.class)) {
            data = info.getAs("BlockData", TagShort.class).getShortData();
        } else if (info.containsKeyAs("BlockData", TagInt.class)) {
            data = info.getAs("BlockData", TagInt.class).getIntData();
        }
        setBlock(new ItemStack(Material.getMaterial(id), 1, (short) data));
    } else if (info.getCompoundData().containsKey("Block")) {
        TagCompound itemStackCompund = info.getAs("Block", TagCompound.class);
        ItemStack block = MyPetApi.getPlatformHelper().compundToItemStack(itemStackCompund);
        setBlock(block);
    }
// setScreaming((()info.getValue().get("Screaming")).getBooleanValue());
}
Also used : TagInt(de.keyle.knbt.TagInt) ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound)

Example 39 with TagCompound

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

the class MyGiant method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    List<TagCompound> itemList = new ArrayList<>();
    for (EquipmentSlot slot : EquipmentSlot.values()) {
        if (getEquipment(slot) != null) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(getEquipment(slot));
            item.getCompoundData().put("Slot", new TagInt(slot.getSlotId()));
            itemList.add(item);
        }
    }
    info.getCompoundData().put("Equipment", new TagList(itemList));
    return info;
}
Also used : ArrayList(java.util.ArrayList) EquipmentSlot(de.Keyle.MyPet.api.entity.EquipmentSlot) TagInt(de.keyle.knbt.TagInt) TagList(de.keyle.knbt.TagList) TagCompound(de.keyle.knbt.TagCompound)

Example 40 with TagCompound

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

the class MyHorse method writeExtendedInfo.

@Override
public TagCompound writeExtendedInfo() {
    TagCompound info = super.writeExtendedInfo();
    info.getCompoundData().put("Type", new TagByte(getHorseType()));
    info.getCompoundData().put("Variant", new TagInt(getVariant()));
    if (hasArmor()) {
        info.getCompoundData().put("Armor", MyPetApi.getPlatformHelper().itemStackToCompund(getArmor()));
    }
    info.getCompoundData().put("Age", new TagInt(getAge()));
    if (hasChest()) {
        info.getCompoundData().put("Chest", MyPetApi.getPlatformHelper().itemStackToCompund(getChest()));
    }
    if (hasSaddle()) {
        info.getCompoundData().put("Saddle", MyPetApi.getPlatformHelper().itemStackToCompund(getSaddle()));
    }
    return info;
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Aggregations

TagCompound (de.keyle.knbt.TagCompound)141 TagInt (de.keyle.knbt.TagInt)53 TagByte (de.keyle.knbt.TagByte)49 TagList (de.keyle.knbt.TagList)47 ItemStack (org.bukkit.inventory.ItemStack)47 ArrayList (java.util.ArrayList)18 TagString (de.keyle.knbt.TagString)12 MyPetBaby (de.Keyle.MyPet.api.entity.MyPetBaby)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 MaterialData (org.bukkit.material.MaterialData)9 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)8 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)5 InactiveMyPet (de.Keyle.MyPet.entity.InactiveMyPet)3 TagShort (de.keyle.knbt.TagShort)3 CraftItemStack (org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_8_R2.inventory.CraftItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack)3 CraftItemStack (org.bukkit.craftbukkit.v1_9_R1.inventory.CraftItemStack)3