use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaItem method readNbtEnchants.
protected static Map<Enchantment, Integer> readNbtEnchants(String name, CompoundTag tag) {
Map<Enchantment, Integer> result = null;
if (tag.isList(name, TagType.COMPOUND)) {
Iterable<CompoundTag> enchs = tag.getCompoundList(name);
for (CompoundTag enchantmentTag : enchs) {
if (enchantmentTag.isShort("id") && enchantmentTag.isShort("lvl")) {
Enchantment enchantment = Enchantment.getById(enchantmentTag.getShort("id"));
if (result == null)
result = new HashMap<>(4);
result.put(enchantment, (int) enchantmentTag.getShort("lvl"));
}
}
}
return result;
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaItem method writeNbtEnchants.
protected static void writeNbtEnchants(String name, CompoundTag to, Map<Enchantment, Integer> enchants) {
List<CompoundTag> ench = new ArrayList<>();
for (Entry<Enchantment, Integer> enchantment : enchants.entrySet()) {
CompoundTag enchantmentTag = new CompoundTag();
enchantmentTag.putShort("id", enchantment.getKey().getId());
enchantmentTag.putShort("lvl", enchantment.getValue());
ench.add(enchantmentTag);
}
to.putCompoundList(name, ench);
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaLeatherArmor method writeNbt.
@Override
void writeNbt(CompoundTag tag) {
super.writeNbt(tag);
if (hasColor()) {
CompoundTag display = new CompoundTag();
display.putInt("color", color.asRGB());
tag.putCompound("display", display);
}
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowItemFactory method writeNbt.
public CompoundTag writeNbt(ItemMeta meta) {
CompoundTag result = new CompoundTag();
toGlowMeta(meta).writeNbt(result);
return result.isEmpty() ? null : result;
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaSpawn method writeNbt.
@Override
void writeNbt(CompoundTag tag) {
super.writeNbt(tag);
CompoundTag entityTag = getEntityTag() != null ? getEntityTag() : new CompoundTag();
if (hasSpawnedType()) {
entityTag.putString("id", "minecraft:" + getSpawnedType().getName());
}
tag.putCompound("EntityTag", entityTag);
}
Aggregations