use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaFirework method readNbt.
@Override
void readNbt(CompoundTag tag) {
CompoundTag firework = tag.getCompound("Fireworks");
power = firework.getByte("Flight");
List<CompoundTag> explosions = firework.getCompoundList("Explosions");
effects.addAll(explosions.stream().map(GlowMetaFireworkEffect::toEffect).collect(Collectors.toList()));
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class GlowMetaFirework method writeNbt.
@Override
void writeNbt(CompoundTag tag) {
CompoundTag firework = new CompoundTag();
tag.putCompound("Fireworks", firework);
firework.putByte("Flight", power);
List<CompoundTag> explosions = new ArrayList<>();
if (hasEffects()) {
explosions.addAll(effects.stream().map(GlowMetaFireworkEffect::toExplosion).collect(Collectors.toList()));
}
firework.putCompoundList("Explosions", explosions);
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class NbtScoreboardIoWriter method writeObjectives.
private static void writeObjectives(CompoundTag root, GlowScoreboard scoreboard) {
List<CompoundTag> objectives = new ArrayList<>();
for (Objective objective : scoreboard.getObjectives()) {
CompoundTag objectiveNbt = new CompoundTag();
objectiveNbt.putString("CriteriaName", objective.getCriteria());
objectiveNbt.putString("DisplayName", objective.getDisplayName());
objectiveNbt.putString("Name", objective.getName());
objectiveNbt.putString("RenderType", objective.getType().name());
objectives.add(objectiveNbt);
}
root.putCompoundList("Objectives", objectives);
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class NbtScoreboardIoWriter method writeMainScoreboard.
public static void writeMainScoreboard(File path, GlowScoreboard scoreboard) throws IOException {
CompoundTag root = new CompoundTag();
CompoundTag data = new CompoundTag();
root.putCompound("data", data);
try (NBTOutputStream nbt = new NBTOutputStream(getDataOutputStream(path), true)) {
writeObjectives(data, scoreboard);
writeScores(data, scoreboard);
writeTeams(data, scoreboard);
writeDisplaySlots(data, scoreboard);
nbt.writeTag(root);
nbt.close();
}
}
use of net.glowstone.util.nbt.CompoundTag in project Glowstone by GlowstoneMC.
the class ItemSpawn method rightClickBlock.
@Override
public void rightClickBlock(GlowPlayer player, GlowBlock against, BlockFace face, ItemStack holding, Vector clickedLoc) {
Location location = against.getLocation().add(face.getModX(), face.getModY(), face.getModZ());
// TODO: change mob spawner when clicked by monster egg
if (holding.hasItemMeta() && holding.getItemMeta() instanceof GlowMetaSpawn) {
GlowMetaSpawn meta = (GlowMetaSpawn) holding.getItemMeta();
EntityType type = meta.getSpawnedType();
CompoundTag tag = meta.getEntityTag();
if (type != null) {
GlowEntity entity = against.getWorld().spawn(location.add(0.5, 0, 0.5), EntityRegistry.getEntity(type), SpawnReason.SPAWNER_EGG);
if (tag != null) {
EntityStorage.load(entity, tag);
}
}
}
}
Aggregations