Package com.sk89q.jnbt

Examples of com.sk89q.jnbt.ListTag


                enchantment.put("lvl", new ShortTag(entry.getValue().shortValue()));
                enchantmentList.add(new CompoundTag(enchantment));
            }

            Map<String, Tag> auxData = new HashMap<String, Tag>();
            auxData.put("ench", new ListTag(CompoundTag.class, enchantmentList));
            data.put("tag", new CompoundTag(auxData));
        }
        return data;
    }
View Full Code Here


        BaseItemStack stack = new BaseItemStack(id, count, damage);

        if (data.containsKey("tag")) {
            Map<String, Tag> auxData = NBTUtils.getChildTag(data, "tag", CompoundTag.class).getValue();
            ListTag ench = (ListTag)auxData.get("ench");
            for(Tag e : ench.getValue()) {
                Map<String, Tag> vars = ((CompoundTag) e).getValue();
                short enchId = NBTUtils.getChildTag(vars, "id", ShortTag.class).getValue();
                short enchLevel = NBTUtils.getChildTag(vars, "lvl", ShortTag.class).getValue();
                stack.getEnchantments().put((int) enchId, (int) enchLevel);
            }
View Full Code Here

        values.put("RequiredPlayerRange", new ShortTag(requiredPlayerRange));
        if (spawnData != null) {
            values.put("SpawnData", new CompoundTag(spawnData.getValue()));
        }
        if (spawnPotentials != null) {
            values.put("SpawnPotentials", new ListTag(CompoundTag.class, spawnPotentials.getValue()));
        }

        return new CompoundTag(values);
    }
View Full Code Here

        ShortTag spawnRangeTag = null;
        ShortTag minSpawnDelayTag = null;
        ShortTag maxSpawnDelayTag = null;
        ShortTag maxNearbyEntitiesTag = null;
        ShortTag requiredPlayerRangeTag = null;
        ListTag spawnPotentialsTag = null;
        CompoundTag spawnDataTag = null;
        try {
            spawnCountTag = NBTUtils.getChildTag(values, "SpawnCount", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            spawnRangeTag = NBTUtils.getChildTag(values, "SpawnRange", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            minSpawnDelayTag = NBTUtils.getChildTag(values, "MinSpawnDelay", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            maxSpawnDelayTag = NBTUtils.getChildTag(values, "MaxSpawnDelay", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            maxNearbyEntitiesTag = NBTUtils.getChildTag(values, "MaxNearbyEntities", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            requiredPlayerRangeTag = NBTUtils.getChildTag(values, "RequiredPlayerRange", ShortTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            spawnPotentialsTag = NBTUtils.getChildTag(values, "SpawnPotentials", ListTag.class);
        } catch (InvalidFormatException ignored) {
        }
        try {
            spawnDataTag = NBTUtils.getChildTag(values, "SpawnData", CompoundTag.class);
        } catch (InvalidFormatException ignored) {
        }

        if (spawnCountTag != null) {
            this.spawnCount = spawnCountTag.getValue();
        }
        if (spawnRangeTag != null) {
            this.spawnRange =spawnRangeTag.getValue();
        }
        if (minSpawnDelayTag != null) {
            this.minSpawnDelay = minSpawnDelayTag.getValue();
        }
        if (maxSpawnDelayTag != null) {
            this.maxSpawnDelay = maxSpawnDelayTag.getValue();
        }
        if (maxNearbyEntitiesTag != null) {
            this.maxNearbyEntities = maxNearbyEntitiesTag.getValue();
        }
        if (requiredPlayerRangeTag != null) {
            this.requiredPlayerRange = requiredPlayerRangeTag.getValue();
        }
        if (spawnPotentialsTag != null) {
            this.spawnPotentials = new ListTag(CompoundTag.class, spawnPotentialsTag.getValue());
        }
        if (spawnDataTag != null) {
            this.spawnData = new CompoundTag(spawnDataTag.getValue());
        }
    }
View Full Code Here

    }

    @Override
    public CompoundTag getNbtData() {
        Map<String, Tag> values = new HashMap<String, Tag>();
        values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
        values.put("BurnTime", new ShortTag(burnTime));
        values.put("CookTime", new ShortTag(cookTime));
        return new CompoundTag(values);
    }
View Full Code Here

            if (!(t instanceof StringTag)
                    || !((StringTag) t).getValue().equals("Furnace")) {
                throw new RuntimeException("'Furnace' tile entity expected");
            }

            ListTag items = NBTUtils.getChildTag(values, "Items", ListTag.class);

            List<CompoundTag> compound = new ArrayList<CompoundTag>();

            for (Tag tag : items.getValue()) {
                if (!(tag instanceof CompoundTag)) {
                    throw new RuntimeException("CompoundTag expected as child tag of Furnace Items");
                }
                compound.add((CompoundTag) tag);
            }
View Full Code Here

    }

    @Override
    public CompoundTag getNbtData() {
        Map<String, Tag> values = new HashMap<String, Tag>();
        values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
        return new CompoundTag(values);
    }
View Full Code Here

    }

    @Override
    public CompoundTag getNbtData() {
        Map<String, Tag> values = new HashMap<String, Tag>();
        values.put("Items", new ListTag(CompoundTag.class, serializeInventory(getItems())));
        return new CompoundTag(values);
    }
View Full Code Here

            }
        }

        schematic.put("Blocks", new ByteArrayTag(blocks));
        schematic.put("Data", new ByteArrayTag(blockData));
        schematic.put("TileEntities", new ListTag(CompoundTag.class, tileEntities));

        if (addBlocks != null) {
            schematic.put("AddBlocks", new ByteArrayTag(addBlocks));
        }

        // ====================================================================
        // Entities
        // ====================================================================

        List<Tag> entities = new ArrayList<Tag>();
        for (Entity entity : clipboard.getEntities()) {
            BaseEntity state = entity.getState();

            if (state != null) {
                Map<String, Tag> values = new HashMap<String, Tag>();

                // Put NBT provided data
                CompoundTag rawTag = state.getNbtData();
                if (rawTag != null) {
                    values.putAll(rawTag.getValue());
                }

                // Store our location data, overwriting any
                values.put("id", new StringTag(state.getTypeId()));
                values.put("Pos", writeVector(entity.getLocation().toVector(), "Pos"));
                values.put("Rotation", writeRotation(entity.getLocation(), "Rotation"));

                CompoundTag entityTag = new CompoundTag(values);
                entities.add(entityTag);
            }
        }

        schematic.put("Entities", new ListTag(CompoundTag.class, entities));

        // ====================================================================
        // Output
        // ====================================================================
View Full Code Here

    private Tag writeVector(Vector vector, String name) {
        List<DoubleTag> list = new ArrayList<DoubleTag>();
        list.add(new DoubleTag(vector.getX()));
        list.add(new DoubleTag(vector.getY()));
        list.add(new DoubleTag(vector.getZ()));
        return new ListTag(DoubleTag.class, list);
    }
View Full Code Here

TOP

Related Classes of com.sk89q.jnbt.ListTag

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.