Search in sources :

Example 11 with DoubleTag

use of cn.nukkit.nbt.tag.DoubleTag in project Nukkit by Nukkit.

the class ItemMinecartHopper method onActivate.

@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    if (Rail.isRailBlock(target)) {
        Rail.Orientation type = ((BlockRail) target).getOrientation();
        double adjacent = 0.0D;
        if (type.isAscending()) {
            adjacent = 0.5D;
        }
        EntityMinecartHopper minecart = new EntityMinecartHopper(level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("").putList(new ListTag<>("Pos").add(new DoubleTag("", target.getX() + 0.5)).add(new DoubleTag("", target.getY() + 0.0625D + adjacent)).add(new DoubleTag("", target.getZ() + 0.5))).putList(new ListTag<>("Motion").add(new DoubleTag("", 0)).add(new DoubleTag("", 0)).add(new DoubleTag("", 0))).putList(new ListTag<>("Rotation").add(new FloatTag("", 0)).add(new FloatTag("", 0))));
        minecart.spawnToAll();
        count -= 1;
        return true;
    }
    return false;
}
Also used : BlockRail(cn.nukkit.block.BlockRail) Rail(cn.nukkit.utils.Rail) FloatTag(cn.nukkit.nbt.tag.FloatTag) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) EntityMinecartHopper(cn.nukkit.entity.item.EntityMinecartHopper) ListTag(cn.nukkit.nbt.tag.ListTag) BlockRail(cn.nukkit.block.BlockRail) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Example 12 with DoubleTag

use of cn.nukkit.nbt.tag.DoubleTag in project Nukkit by Nukkit.

the class ItemMinecartTNT method onActivate.

@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    if (Rail.isRailBlock(target)) {
        Rail.Orientation type = ((BlockRail) target).getOrientation();
        double adjacent = 0.0D;
        if (type.isAscending()) {
            adjacent = 0.5D;
        }
        EntityMinecartTNT minecart = new EntityMinecartTNT(level.getChunk(target.getFloorX() >> 4, target.getFloorZ() >> 4), new CompoundTag("").putList(new ListTag<>("Pos").add(new DoubleTag("", target.getX() + 0.5)).add(new DoubleTag("", target.getY() + 0.0625D + adjacent)).add(new DoubleTag("", target.getZ() + 0.5))).putList(new ListTag<>("Motion").add(new DoubleTag("", 0)).add(new DoubleTag("", 0)).add(new DoubleTag("", 0))).putList(new ListTag<>("Rotation").add(new FloatTag("", 0)).add(new FloatTag("", 0))));
        minecart.spawnToAll();
        count -= 1;
        return true;
    }
    return false;
}
Also used : BlockRail(cn.nukkit.block.BlockRail) Rail(cn.nukkit.utils.Rail) FloatTag(cn.nukkit.nbt.tag.FloatTag) EntityMinecartTNT(cn.nukkit.entity.item.EntityMinecartTNT) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) ListTag(cn.nukkit.nbt.tag.ListTag) BlockRail(cn.nukkit.block.BlockRail) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Example 13 with DoubleTag

use of cn.nukkit.nbt.tag.DoubleTag in project Nukkit by Nukkit.

the class Server method getOfflinePlayerData.

public CompoundTag getOfflinePlayerData(String name) {
    name = name.toLowerCase();
    String path = this.getDataPath() + "players/";
    File file = new File(path + name + ".dat");
    if (this.shouldSavePlayerData() && file.exists()) {
        try {
            return NBTIO.readCompressed(new FileInputStream(file));
        } catch (Exception e) {
            file.renameTo(new File(path + name + ".dat.bak"));
            this.logger.notice(this.getLanguage().translateString("nukkit.data.playerCorrupted", name));
        }
    } else {
        this.logger.notice(this.getLanguage().translateString("nukkit.data.playerNotFound", name));
    }
    Position spawn = this.getDefaultLevel().getSafeSpawn();
    CompoundTag nbt = new CompoundTag().putLong("firstPlayed", System.currentTimeMillis() / 1000).putLong("lastPlayed", System.currentTimeMillis() / 1000).putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("0", spawn.x)).add(new DoubleTag("1", spawn.y)).add(new DoubleTag("2", spawn.z))).putString("Level", this.getDefaultLevel().getName()).putList(new ListTag<>("Inventory")).putCompound("Achievements", new CompoundTag()).putInt("playerGameType", this.getGamemode()).putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("0", 0)).add(new DoubleTag("1", 0)).add(new DoubleTag("2", 0))).putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("0", 0)).add(new FloatTag("1", 0))).putFloat("FallDistance", 0).putShort("Fire", 0).putShort("Air", 300).putBoolean("OnGround", true).putBoolean("Invulnerable", false).putString("NameTag", name);
    this.saveOfflinePlayerData(name, nbt);
    return nbt;
}
Also used : FloatTag(cn.nukkit.nbt.tag.FloatTag) Position(cn.nukkit.level.Position) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) ListTag(cn.nukkit.nbt.tag.ListTag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

CompoundTag (cn.nukkit.nbt.tag.CompoundTag)13 DoubleTag (cn.nukkit.nbt.tag.DoubleTag)13 FloatTag (cn.nukkit.nbt.tag.FloatTag)13 ListTag (cn.nukkit.nbt.tag.ListTag)13 BlockRail (cn.nukkit.block.BlockRail)4 Rail (cn.nukkit.utils.Rail)4 Entity (cn.nukkit.entity.Entity)3 EntityProjectile (cn.nukkit.entity.projectile.EntityProjectile)2 ProjectileLaunchEvent (cn.nukkit.event.entity.ProjectileLaunchEvent)2 FullChunk (cn.nukkit.level.format.FullChunk)2 Random (java.util.Random)2 Player (cn.nukkit.Player)1 BlockAir (cn.nukkit.block.BlockAir)1 EntityBoat (cn.nukkit.entity.item.EntityBoat)1 EntityFallingBlock (cn.nukkit.entity.item.EntityFallingBlock)1 EntityMinecartChest (cn.nukkit.entity.item.EntityMinecartChest)1 EntityMinecartEmpty (cn.nukkit.entity.item.EntityMinecartEmpty)1 EntityMinecartHopper (cn.nukkit.entity.item.EntityMinecartHopper)1 EntityMinecartTNT (cn.nukkit.entity.item.EntityMinecartTNT)1 EntityPainting (cn.nukkit.entity.item.EntityPainting)1