Package net.canarymod.api.nbt

Examples of net.canarymod.api.nbt.CompoundTag


            return null;
        }
        ListTag<CompoundTag> stored_enchantments = book.getDataTag().getListTag("StoredEnchantments");
        Enchantment[] enchantments = new Enchantment[stored_enchantments.size()];
        for (int index = 0; index < stored_enchantments.size(); index++) {
            CompoundTag stored_enchantment = stored_enchantments.get(index);
            enchantments[index] = Canary.factory().getItemFactory().newEnchantment(stored_enchantment.getShort("id"), stored_enchantment.getShort("lvl"));
        }
        return enchantments;
    }
View Full Code Here


        ListTag<CompoundTag> sto_ench = STORED_ENCH_TAG.copy();
        for (Enchantment ench : enchantments) {
            if (ench == null) {
                continue;
            }
            CompoundTag ench_tag = ENCH_TAG.copy();
            ench_tag.put("lvl", ench.getLevel());
            ench_tag.put("id", ench.getType().getId());
            success &= sto_ench.add(ench_tag);
        }
        book.getDataTag().put("StoredEnchantments", sto_ench);
        return success;
    }
View Full Code Here

        ListTag<CompoundTag> sto_ench = book.getDataTag().getListTag("StoredEnchantments");
        for (Enchantment ench : enchantments) {
            if (ench == null) {
                continue;
            }
            CompoundTag ench_tag = ENCH_TAG.copy();
            ench_tag.put("lvl", ench.getLevel());
            ench_tag.put("id", (short) ench.getType().getId());
            success &= sto_ench.add(ench_tag);
        }
        return success;
    }
View Full Code Here

        }
        boolean success = true;
        ListTag<CompoundTag> sto_enchs = book.getDataTag().getListTag("StoredEnchantments");
        Iterator<CompoundTag> tagItr = sto_enchs.iterator();
        while (tagItr.hasNext()) {
            CompoundTag sto_ench = tagItr.next();
            boolean found = false;
            for (Enchantment ench : enchantments) {
                if (sto_ench.getShort("id") == ench.getType().getId() && sto_ench.getShort("lvl") == ench.getLevel()) {
                    tagItr.remove();
                    found = true;
                }
            }
            success &= found;
View Full Code Here

            return null;
        }
        ListTag<CompoundTag> effects = potion.getDataTag().getListTag("CustomPotionEffects");
        PotionEffect[] potion_effects = new PotionEffect[effects.size()];
        for (int index = 0; index < effects.size(); index++) {
            CompoundTag effect = effects.get(index);
            potion_effects[index] = Canary.factory().getPotionFactory().newPotionEffect(effect.getByte("Id"), effect.getInt("Duration"), effect.getByte("Amplifier"), effect.getBoolean("Ambient"));
        }
        return potion_effects;
    }
View Full Code Here

        boolean success = true;
        for (PotionEffect effect : effects) {
            if (effect == null) {
                continue;
            }
            CompoundTag potion_effect = TAG.copy();
            potion_effect.put("Id", (byte) effect.getPotionID());
            potion_effect.put("Duration", effect.getDuration());
            potion_effect.put("Amplifier", (byte) effect.getAmplifier());
            potion_effect.put("Ambient", effect.isAmbient());
            success &= potion_effects.add(potion_effect);
        }
        return success;
    }
View Full Code Here

        boolean success = true;
        for (PotionEffect effect : effects) {
            if (effect == null) {
                continue;
            }
            CompoundTag potion_effect = TAG.copy();
            potion_effect.setName("");
            potion_effect.put("Id", (byte) effect.getPotionID());
            potion_effect.put("Duration", effect.getDuration());
            potion_effect.put("Amplifier", (byte) effect.getAmplifier());
            potion_effect.put("Ambient", effect.isAmbient());
            success &= potion_effects.add(potion_effect);
        }
        return success;
    }
View Full Code Here

        }
        ListTag<CompoundTag> custom_effects = potion.getDataTag().getListTag("CustomPotionEffects");
        Iterator<CompoundTag> tagItr = custom_effects.iterator();
        boolean success = true;
        while (tagItr.hasNext()) {
            CompoundTag custom_effect = tagItr.next();
            boolean found = false;
            for (PotionEffect effect : effects) {
                if (custom_effect.getByte("Id") == effect.getPotionID() && custom_effect.getInt("Duration") == effect.getDuration() &&
                        custom_effect.getByte("Amplifier") == effect.getPotionID() && custom_effect.getBoolean("Ambient") == effect.isAmbient()) {
                    tagItr.remove();
                    found = true;
                }
            }
            success &= found;
View Full Code Here

TOP

Related Classes of net.canarymod.api.nbt.CompoundTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.