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