Search in sources :

Example 1 with TagByte

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

the class EntityConverterService method convertHorse.

public void convertHorse(Horse horse, TagCompound properties) {
    byte type = (byte) horse.getVariant().ordinal();
    int style = horse.getStyle().ordinal();
    int color = horse.getColor().ordinal();
    int variant = color & 255 | style << 8;
    if (horse.getInventory().getArmor() != null) {
        TagCompound armor = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getArmor());
        properties.getCompoundData().put("Armor", armor);
    }
    if (horse.getInventory().getSaddle() != null) {
        TagCompound saddle = MyPetApi.getPlatformHelper().itemStackToCompund(horse.getInventory().getSaddle());
        properties.getCompoundData().put("Saddle", saddle);
    }
    properties.getCompoundData().put("Type", new TagByte(type));
    properties.getCompoundData().put("Variant", new TagInt(variant));
    properties.getCompoundData().put("Chest", new TagByte(horse.isCarryingChest()));
    properties.getCompoundData().put("Age", new TagInt(horse.getAge()));
    if (horse.isCarryingChest()) {
        ItemStack[] contents = horse.getInventory().getContents();
        for (int i = 2; i < contents.length; i++) {
            ItemStack item = contents[i];
            if (item != null) {
                horse.getWorld().dropItem(horse.getLocation(), item);
            }
        }
    }
}
Also used : TagInt(de.keyle.knbt.TagInt) ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 2 with TagByte

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

the class EntityConverterService method convertWolf.

public void convertWolf(Wolf wolf, TagCompound properties) {
    properties.getCompoundData().put("Sitting", new TagByte(wolf.isSitting()));
    properties.getCompoundData().put("Tamed", new TagByte(wolf.isTamed()));
    properties.getCompoundData().put("CollarColor", new TagByte(wolf.getCollarColor().getWoolData()));
}
Also used : TagByte(de.keyle.knbt.TagByte)

Example 3 with TagByte

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

the class CustomInventory method save.

public TagCompound save(TagCompound compound) {
    List<TagCompound> itemList = new ArrayList<>();
    for (int i = 0; i < this.items.size(); i++) {
        ItemStack itemStack = this.items.get(i);
        if (itemStack != null) {
            TagCompound item = ItemStackNBTConverter.itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagByte((byte) i));
            itemList.add(item);
        }
    }
    compound.getCompoundData().put("Items", new TagList(itemList));
    return compound;
}
Also used : ArrayList(java.util.ArrayList) TagList(de.keyle.knbt.TagList) CraftItemStack(org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack) TagCompound(de.keyle.knbt.TagCompound) TagByte(de.keyle.knbt.TagByte)

Example 4 with TagByte

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

the class EntityConverterService method convertOcelot.

public void convertOcelot(Ocelot ocelot, TagCompound properties) {
    properties.getCompoundData().put("CatType", new TagInt(ocelot.getCatType().getId()));
    properties.getCompoundData().put("Sitting", new TagByte(ocelot.isSitting()));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagByte(de.keyle.knbt.TagByte)

Example 5 with TagByte

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

the class EntityConverterService method convertWolf.

public void convertWolf(Wolf wolf, TagCompound properties) {
    properties.getCompoundData().put("Sitting", new TagByte(wolf.isSitting()));
    properties.getCompoundData().put("Tamed", new TagByte(wolf.isTamed()));
    properties.getCompoundData().put("CollarColor", new TagByte(wolf.getCollarColor().getWoolData()));
}
Also used : TagByte(de.keyle.knbt.TagByte)

Aggregations

TagByte (de.keyle.knbt.TagByte)95 TagCompound (de.keyle.knbt.TagCompound)57 TagInt (de.keyle.knbt.TagInt)42 TagList (de.keyle.knbt.TagList)15 ArrayList (java.util.ArrayList)15 ItemStack (org.bukkit.inventory.ItemStack)7 TagString (de.keyle.knbt.TagString)4 TagDouble (de.keyle.knbt.TagDouble)3 TagByteArray (de.keyle.knbt.TagByteArray)2 TagFloat (de.keyle.knbt.TagFloat)2 TagIntArray (de.keyle.knbt.TagIntArray)2 TagLong (de.keyle.knbt.TagLong)2 TagShort (de.keyle.knbt.TagShort)2 List (java.util.List)2 ByteArrayTag (net.minecraft.nbt.ByteArrayTag)2 ByteTag (net.minecraft.nbt.ByteTag)2 CompoundTag (net.minecraft.nbt.CompoundTag)2 DoubleTag (net.minecraft.nbt.DoubleTag)2 FloatTag (net.minecraft.nbt.FloatTag)2 IntArrayTag (net.minecraft.nbt.IntArrayTag)2