Package net.glowstone.util.nbt

Examples of net.glowstone.util.nbt.CompoundTag


        String name = tag.getString("Name");

        List<PlayerProperty> properties = new ArrayList<>();
        if (tag.containsKey("Properties")) {
            for (Map.Entry<String, Tag> property : tag.getCompound("Properties").getValue().entrySet()) {
                CompoundTag propertyValueTag = ((List<CompoundTag>) property.getValue().getValue()).get(0);
                properties.add(new PlayerProperty(property.getKey(), propertyValueTag.getString("Value"), propertyValueTag.getString("Signature")));
            }
        }
        return new PlayerProfile(name, UUID.fromString(uuidStr), properties);
    }
View Full Code Here


                .withFade(fadeColors)
                .build();
    }

    static CompoundTag toExplosion(FireworkEffect effect) {
        CompoundTag explosion = new CompoundTag();

        if (effect.hasFlicker()) explosion.putBool("Flicker", true);
        if (effect.hasTrail()) explosion.putBool("Trail", true);

        explosion.putByte("Type", effect.getType().ordinal());

        List<Color> colors = effect.getColors();
        List<Integer> colorInts = new ArrayList<>();
        for (Color color : colors) {
            colorInts.add(color.asRGB());
        }
        explosion.putIntArray("Colors", Ints.toArray(colorInts));

        List<Color> fade = effect.getFadeColors();
        if (!fade.isEmpty()) {
            List<Integer> fadeInts = new ArrayList<>();
            for (Color color : colors) {
                fadeInts.add(color.asRGB());
            }
            explosion.putIntArray("FadeColors", Ints.toArray(fadeInts));
        }

        return explosion;
    }
View Full Code Here

    }

    @Override
    public void update(GlowPlayer player) {
        super.update(player);
        CompoundTag nbt = new CompoundTag();
        saveNbt(nbt);
        player.sendBlockEntityChange(getBlock().getLocation(), GlowBlockEntity.BANNER, nbt);
    }
View Full Code Here

        return result;
    }

    void writeNbt(CompoundTag tag) {
        CompoundTag displayTags = new CompoundTag();
        if (hasDisplayName()) {
            displayTags.putString("Name", getDisplayName());
        }
        if (hasLore()) {
            displayTags.putList("Lore", TagType.STRING, getLore());
        }

        if (!displayTags.isEmpty()) {
            tag.putCompound("display", displayTags);
        }

        // todo: enchantments
    }
View Full Code Here

        // todo: enchantments
    }

    void readNbt(CompoundTag tag) {
        if (tag.isCompound("display")) {
            CompoundTag display = tag.getCompound("display");
            if (display.isString("Name")) {
                setDisplayName(display.getString("Name"));
            }
            if (display.isList("Lore", TagType.STRING)) {
                setLore(display.<String>getList("Lore", TagType.STRING));
            }
        }

        // todo: enchantments
    }
View Full Code Here

    public Color getDefaultLeatherColor() {
        return LEATHER_COLOR;
    }

    public CompoundTag writeNbt(ItemMeta meta) {
        CompoundTag result = new CompoundTag();
        toGlowMeta(meta).writeNbt(result);
        return result.isEmpty() ? null : result;
    }
View Full Code Here

    }

    @Override
    void writeNbt(CompoundTag tag) {
        super.writeNbt(tag);
        CompoundTag blockEntityTag = new CompoundTag();

        blockEntityTag.putCompoundList("Patterns", BlockBanner.toNBT(pattern));
        tag.putCompound("BlockEntityTag", blockEntityTag);
    }
View Full Code Here

    @Override
    void readNbt(CompoundTag tag) {
        super.readNbt(tag);
        if (tag.isCompound("BlockEntityTag")) {
            CompoundTag blockEntityTag = tag.getCompound("BlockEntityTag");
            if (blockEntityTag.isList("Patterns", TagType.COMPOUND)) {
                List<CompoundTag> pattern = blockEntityTag.getCompoundList("Patterns");
                this.pattern = BlockBanner.fromNBT(pattern);
            }
        }
    }
View Full Code Here

    }

    public static List<CompoundTag> toNBT(BannerPattern pattern) {
        List<CompoundTag> patterns = new ArrayList<>();
        for (BannerPattern.BannerLayer layer : pattern.getLayers()) {
            CompoundTag layerTag = new CompoundTag();
            layerTag.putString("Pattern", layer.getTexture().getCode());
            layerTag.putInt("Color", layer.getColor().getDyeData());
            patterns.add(layerTag);
        }
        return patterns;
    }
View Full Code Here

        return result;
    }

    @Override
    void writeNbt(CompoundTag tag) {
        CompoundTag firework = new CompoundTag();
        tag.putCompound("Fireworks", firework);
        firework.putByte("Flight", power);

        List<CompoundTag> explosions = new ArrayList<>();
        if (hasEffects()) {
            for (FireworkEffect effect : effects) {
                explosions.add(GlowMetaFireworkEffect.toExplosion(effect));
            }
        }
        firework.putCompoundList("Explosions", explosions);
    }
View Full Code Here

TOP

Related Classes of net.glowstone.util.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.