Search in sources :

Example 51 with TagInt

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

the class EntityConverterService method convertEquipable.

public void convertEquipable(LivingEntity entity, TagCompound properties) {
    List<TagCompound> equipmentList = new ArrayList<>();
    if (random.nextFloat() <= entity.getEquipment().getChestplateDropChance()) {
        ItemStack itemStack = entity.getEquipment().getChestplate();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Chestplate.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getHelmetDropChance()) {
        ItemStack itemStack = entity.getEquipment().getHelmet();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Helmet.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getLeggingsDropChance()) {
        ItemStack itemStack = entity.getEquipment().getLeggings();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Leggins.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getBootsDropChance()) {
        ItemStack itemStack = entity.getEquipment().getBoots();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Boots.getSlotId()));
            equipmentList.add(item);
        }
    }
    properties.getCompoundData().put("Equipment", new TagList(equipmentList));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagList(de.keyle.knbt.TagList) ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound)

Example 52 with TagInt

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

the class EntityConverterService method convertSheep.

public void convertSheep(Sheep sheep, TagCompound properties) {
    properties.getCompoundData().put("Color", new TagInt(sheep.getColor().getDyeData()));
    properties.getCompoundData().put("Sheared", new TagByte(sheep.isSheared()));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagByte(de.keyle.knbt.TagByte)

Example 53 with TagInt

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

the class EntityConverterService method convertEquipable.

public void convertEquipable(LivingEntity entity, TagCompound properties) {
    List<TagCompound> equipmentList = new ArrayList<>();
    if (random.nextFloat() <= entity.getEquipment().getChestplateDropChance()) {
        ItemStack itemStack = entity.getEquipment().getChestplate();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Chestplate.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getHelmetDropChance()) {
        ItemStack itemStack = entity.getEquipment().getHelmet();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Helmet.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getLeggingsDropChance()) {
        ItemStack itemStack = entity.getEquipment().getLeggings();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Leggins.getSlotId()));
            equipmentList.add(item);
        }
    }
    if (random.nextFloat() <= entity.getEquipment().getBootsDropChance()) {
        ItemStack itemStack = entity.getEquipment().getBoots();
        if (itemStack != null && itemStack.getType() != Material.AIR) {
            TagCompound item = MyPetApi.getPlatformHelper().itemStackToCompund(itemStack);
            item.getCompoundData().put("Slot", new TagInt(EquipmentSlot.Boots.getSlotId()));
            equipmentList.add(item);
        }
    }
    properties.getCompoundData().put("Equipment", new TagList(equipmentList));
}
Also used : TagInt(de.keyle.knbt.TagInt) TagList(de.keyle.knbt.TagList) ItemStack(org.bukkit.inventory.ItemStack) TagCompound(de.keyle.knbt.TagCompound)

Example 54 with TagInt

use of de.keyle.knbt.TagInt 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 55 with TagInt

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

the class EntityConverterService method convertVillager.

public void convertVillager(Villager villager, TagCompound properties) {
    int profession = villager.getProfession().ordinal();
    if (MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.10") >= 0) {
        profession--;
    }
    properties.getCompoundData().put("Profession", new TagInt(profession));
    TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(villager);
    String[] allowedTags = { "Riches", "Career", "CareerLevel", "Willing", "Inventory", "Offers" };
    Set<String> keys = new HashSet<>(villagerTag.getCompoundData().keySet());
    for (String key : keys) {
        if (Arrays.binarySearch(allowedTags, key) > -1) {
            continue;
        }
        villagerTag.remove(key);
    }
    properties.getCompoundData().put("OriginalData", villagerTag);
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound)

Aggregations

TagInt (de.keyle.knbt.TagInt)75 TagCompound (de.keyle.knbt.TagCompound)42 TagByte (de.keyle.knbt.TagByte)36 ItemStack (org.bukkit.inventory.ItemStack)20 TagList (de.keyle.knbt.TagList)17 TagString (de.keyle.knbt.TagString)10 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)8 ArrayList (java.util.ArrayList)8 TagDouble (de.keyle.knbt.TagDouble)4