Search in sources :

Example 36 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.

the class GlowMetaBanner method writeNbt.

@Override
void writeNbt(CompoundTag tag) {
    super.writeNbt(tag);
    CompoundTag blockEntityTag = new CompoundTag();
    blockEntityTag.putCompoundList("Patterns", BlockBanner.toNBT(patterns));
    if (baseColor != null) {
        blockEntityTag.putInt("Base", baseColor.getWoolData());
    }
    tag.putCompound("BlockEntityTag", blockEntityTag);
}
Also used : CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 37 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.

the class GlowMetaBanner method readNbt.

@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> patterns = blockEntityTag.getCompoundList("Patterns");
            this.patterns = BlockBanner.fromNBT(patterns);
        }
        if (blockEntityTag.isInt("Base")) {
            this.baseColor = DyeColor.getByWoolData((byte) blockEntityTag.getInt("Base"));
        }
    }
}
Also used : CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 38 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.

the class GlowMetaFireworkEffect method toExplosion.

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 = colors.stream().map(Color::asRGB).collect(Collectors.toList());
    explosion.putIntArray("Colors", Ints.toArray(colorInts));
    List<Color> fade = effect.getFadeColors();
    if (!fade.isEmpty()) {
        List<Integer> fadeInts = fade.stream().map(Color::asRGB).collect(Collectors.toList());
        explosion.putIntArray("FadeColors", Ints.toArray(fadeInts));
    }
    return explosion;
}
Also used : Color(org.bukkit.Color) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 39 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.

the class UpdateBlockEntityCodec method decode.

@Override
public UpdateBlockEntityMessage decode(ByteBuf buffer) throws IOException {
    BlockVector pos = GlowBufUtils.readBlockPosition(buffer);
    int action = buffer.readByte();
    CompoundTag nbt = GlowBufUtils.readCompound(buffer);
    return new UpdateBlockEntityMessage(pos.getBlockX(), pos.getBlockY(), pos.getBlockZ(), action, nbt);
}
Also used : UpdateBlockEntityMessage(net.glowstone.net.message.play.game.UpdateBlockEntityMessage) BlockVector(org.bukkit.util.BlockVector) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 40 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.

the class ProtocolTestUtils method getTag.

public static CompoundTag getTag() {
    CompoundTag tag = new CompoundTag();
    tag.putInt("int", 5);
    tag.putString("string", "text");
    tag.putList("list", TagType.FLOAT, Arrays.asList(1.f, 2.f, 3.f));
    tag.putCompound("compound", new CompoundTag());
    return tag;
}
Also used : CompoundTag(net.glowstone.util.nbt.CompoundTag)

Aggregations

CompoundTag (net.glowstone.util.nbt.CompoundTag)58 ArrayList (java.util.ArrayList)9 NBTInputStream (net.glowstone.util.nbt.NBTInputStream)7 Location (org.bukkit.Location)7 IOException (java.io.IOException)6 NBTOutputStream (net.glowstone.util.nbt.NBTOutputStream)5 File (java.io.File)4 FileInputStream (java.io.FileInputStream)3 BlockEntity (net.glowstone.block.entity.BlockEntity)3 GlowEntity (net.glowstone.entity.GlowEntity)3 ByteBuf (io.netty.buffer.ByteBuf)2 FileOutputStream (java.io.FileOutputStream)2 UUID (java.util.UUID)2 ChunkSection (net.glowstone.chunk.ChunkSection)2 AttributeManager (net.glowstone.entity.AttributeManager)2 Modifier (net.glowstone.entity.AttributeManager.Modifier)2 GlowStructure (net.glowstone.generator.structures.GlowStructure)2 StructureBoundingBox (net.glowstone.generator.structures.util.StructureBoundingBox)2 MojangsonParseException (net.glowstone.util.mojangson.ex.MojangsonParseException)2 Material (org.bukkit.Material)2