Package com.sk89q.jnbt

Examples of com.sk89q.jnbt.ShortTag


        return true;
    }

    public Map<String, Tag> serializeItem(BaseItemStack item) {
        Map<String, Tag> data = new HashMap<String, Tag>();
        data.put("id", new ShortTag((short) item.getType()));
        data.put("Damage", new ShortTag(item.getData()));
        data.put("Count", new ByteTag((byte) item.getAmount()));
        if (!item.getEnchantments().isEmpty()) {
            List<CompoundTag> enchantmentList = new ArrayList<CompoundTag>();
            for(Map.Entry<Integer, Integer> entry : item.getEnchantments().entrySet()) {
                Map<String, Tag> enchantment = new HashMap<String, Tag>();
                enchantment.put("id", new ShortTag(entry.getKey().shortValue()));
                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));
View Full Code Here


    @Override
    public CompoundTag getNbtData() {
        Map<String, Tag> values = new HashMap<String, Tag>();
        values.put("EntityId", new StringTag(mobType));
        values.put("Delay", new ShortTag(delay));
        values.put("SpawnCount", new ShortTag(spawnCount));
        values.put("SpawnRange", new ShortTag(spawnRange));
        values.put("MinSpawnDelay", new ShortTag(minSpawnDelay));
        values.put("MaxSpawnDelay", new ShortTag(maxSpawnDelay));
        values.put("MaxNearbyEntities", new ShortTag(maxNearbyEntities));
        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()));
View Full Code Here

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

        StringTag mobTypeTag;
        ShortTag delayTag;

        try {
            mobTypeTag = NBTUtils.getChildTag(values, "EntityId", StringTag.class);
            delayTag = NBTUtils.getChildTag(values, "Delay", ShortTag.class);
        } catch (InvalidFormatException ignored) {
            throw new RuntimeException("Invalid mob spawner data: no EntityId and/or no Delay");
        }

        this.mobType = mobTypeTag.getValue();
        this.delay = delayTag.getValue();

        ShortTag spawnCountTag = null;
        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) {
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

        // ====================================================================
        // Metadata
        // ====================================================================

        HashMap<String, Tag> schematic = new HashMap<String, Tag>();
        schematic.put("Width", new ShortTag((short) width));
        schematic.put("Length", new ShortTag((short) length));
        schematic.put("Height", new ShortTag((short) height));
        schematic.put("Materials", new StringTag("Alpha"));
        schematic.put("WEOriginX", new IntTag(min.getBlockX()));
        schematic.put("WEOriginY", new IntTag(min.getBlockY()));
        schematic.put("WEOriginZ", new IntTag(min.getBlockZ()));
        schematic.put("WEOffsetX", new IntTag(offset.getBlockX()));
View Full Code Here

        if (length > MAX_SIZE) {
            throw new DataException("Length of region too large for a .schematic");
        }

        HashMap<String, Tag> schematic = new HashMap<String, Tag>();
        schematic.put("Width", new ShortTag((short) width));
        schematic.put("Length", new ShortTag((short) length));
        schematic.put("Height", new ShortTag((short) height));
        schematic.put("Materials", new StringTag("Alpha"));
        schematic.put("WEOriginX", new IntTag(clipboard.getOrigin().getBlockX()));
        schematic.put("WEOriginY", new IntTag(clipboard.getOrigin().getBlockY()));
        schematic.put("WEOriginZ", new IntTag(clipboard.getOrigin().getBlockZ()));
        schematic.put("WEOffsetX", new IntTag(clipboard.getOffset().getBlockX()));
View Full Code Here

TOP

Related Classes of com.sk89q.jnbt.ShortTag

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.