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);
}
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"));
}
}
}
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;
}
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);
}
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;
}
Aggregations