Search in sources :

Example 86 with TagInt

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

the class MyAxolotl method writeExtendedInfo.

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

Example 87 with TagInt

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

the class EntityConverterService method convertTropicalFish.

public void convertTropicalFish(TropicalFish tropicalFish, TagCompound properties) {
    CraftTropicalFish fish = (CraftTropicalFish) tropicalFish;
    properties.getCompoundData().put("Variant", new TagInt(fish.getHandle().getVariant()));
}
Also used : TagInt(de.keyle.knbt.TagInt) CraftTropicalFish(org.bukkit.craftbukkit.v1_17_R1.entity.CraftTropicalFish)

Example 88 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 : ArrayList(java.util.ArrayList) TagInt(de.keyle.knbt.TagInt) TagList(de.keyle.knbt.TagList) ItemStack(org.bukkit.inventory.ItemStack) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) TagCompound(de.keyle.knbt.TagCompound)

Example 89 with TagInt

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

the class EntityConverterService method convertHorse.

public void convertHorse(Horse horse, TagCompound properties) {
    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);
    }
    properties.getCompoundData().put("Variant", new TagInt(variant));
    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) CraftItemStack(org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack) TagCompound(de.keyle.knbt.TagCompound)

Example 90 with TagInt

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

the class EntityConverterService method convertZombieVillager.

public void convertZombieVillager(ZombieVillager zombie, TagCompound properties) {
    properties.getCompoundData().put("Profession", new TagInt(zombie.getVillagerProfession().ordinal()));
    TagCompound villagerTag = MyPetApi.getPlatformHelper().entityToTag(zombie);
    Set<String> allowedTags = Sets.newHashSet("VillagerData");
    Set<String> keys = new HashSet<>(villagerTag.getCompoundData().keySet());
    for (String key : keys) {
        if (allowedTags.contains(key)) {
            continue;
        }
        villagerTag.remove(key);
    }
    properties.getCompoundData().put("VillagerData", villagerTag);
}
Also used : TagInt(de.keyle.knbt.TagInt) TagCompound(de.keyle.knbt.TagCompound) HashSet(java.util.HashSet)

Aggregations

TagInt (de.keyle.knbt.TagInt)98 TagCompound (de.keyle.knbt.TagCompound)57 TagByte (de.keyle.knbt.TagByte)43 ItemStack (org.bukkit.inventory.ItemStack)24 TagList (de.keyle.knbt.TagList)16 TagString (de.keyle.knbt.TagString)13 ArrayList (java.util.ArrayList)10 HashSet (java.util.HashSet)7 TagDouble (de.keyle.knbt.TagDouble)6 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)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