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