Search in sources :

Example 26 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Dragonet-Legacy by DragonetMC.

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)

Example 27 with CompoundTag

use of net.glowstone.util.nbt.CompoundTag in project Dragonet-Legacy by DragonetMC.

the class PEInventorySlot method readSlot.

public static PEInventorySlot readSlot(PEBinaryReader reader) throws IOException {
    //Unsigned
    short id = (short) (reader.readShort() & 0xFFFF);
    if (id <= 0) {
        return new PEInventorySlot((short) 0, (byte) 0, (short) 0);
    }
    byte count = reader.readByte();
    short meta = reader.readShort();
    short lNbt = reader.readShort();
    if (lNbt <= 0) {
        return new PEInventorySlot(id, count, meta);
    }
    byte[] nbtData = reader.read(lNbt);
    NBTInputStream nbtin = new NBTInputStream(new ByteArrayInputStream(nbtData));
    CompoundTag nbt = nbtin.readCompound();
    nbtin.close();
    return new PEInventorySlot(id, count, meta, nbt);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) NBTInputStream(net.glowstone.util.nbt.NBTInputStream) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 28 with CompoundTag

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

the class BlockBanner method fromNBT.

public static List<Pattern> fromNBT(List<CompoundTag> tag) {
    List<Pattern> banner = new ArrayList<>();
    for (CompoundTag layer : tag) {
        PatternType patternType = PatternType.getByIdentifier(layer.getString("Pattern"));
        DyeColor color = DyeColor.getByDyeData((byte) layer.getInt("Color"));
        banner.add(new Pattern(color, patternType));
    }
    return banner;
}
Also used : PatternType(org.bukkit.block.banner.PatternType) Pattern(org.bukkit.block.banner.Pattern) ArrayList(java.util.ArrayList) DyeColor(org.bukkit.DyeColor) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 29 with CompoundTag

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

the class BlockBanner method toNBT.

public static List<CompoundTag> toNBT(List<Pattern> banner) {
    List<CompoundTag> patterns = new ArrayList<>();
    for (Pattern pattern : banner) {
        CompoundTag layerTag = new CompoundTag();
        layerTag.putString("Pattern", pattern.getPattern().getIdentifier());
        layerTag.putInt("Color", pattern.getColor().getDyeData());
        patterns.add(layerTag);
    }
    return patterns;
}
Also used : Pattern(org.bukkit.block.banner.Pattern) ArrayList(java.util.ArrayList) CompoundTag(net.glowstone.util.nbt.CompoundTag)

Example 30 with CompoundTag

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

the class PlayerProfile method toNBT.

public CompoundTag toNBT() {
    CompoundTag profileTag = new CompoundTag();
    profileTag.putString("Id", uniqueId.toString());
    profileTag.putString("Name", name);
    CompoundTag propertiesTag = new CompoundTag();
    for (PlayerProperty property : properties) {
        CompoundTag propertyValueTag = new CompoundTag();
        if (property.isSigned()) {
            propertyValueTag.putString("Signature", property.getSignature());
        }
        propertyValueTag.putString("Value", property.getValue());
        propertiesTag.putCompoundList(property.getName(), Arrays.asList(propertyValueTag));
    }
    if (!propertiesTag.isEmpty()) {
        // Only add properties if not empty
        profileTag.putCompound("Properties", propertiesTag);
    }
    return profileTag;
}
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