本文整理汇总了Java中cn.nukkit.nbt.tag.DoubleTag类的典型用法代码示例。如果您正苦于以下问题:Java DoubleTag类的具体用法?Java DoubleTag怎么用?Java DoubleTag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DoubleTag类属于cn.nukkit.nbt.tag包,在下文中一共展示了DoubleTag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prime
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public void prime(int fuse) {
this.getLevel().setBlock(this, new BlockAir(), true);
double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", this.x + 0.5))
.add(new DoubleTag("", this.y))
.add(new DoubleTag("", this.z + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", -Math.sin(mot) * 0.02))
.add(new DoubleTag("", 0.2))
.add(new DoubleTag("", -Math.cos(mot) * 0.02)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
.putByte("Fuse", fuse);
Entity tnt = new EntityPrimedTNT(
this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4),
nbt
);
tnt.spawnToAll();
this.level.addSound(new TNTPrimeSound(this));
}
示例2: dropExpOrb
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public void dropExpOrb(Vector3 source, int exp, Vector3 motion, int delay) {
motion = (motion == null) ? new Vector3(new java.util.Random().nextDouble() * 0.2 - 0.1, 0.2,
new java.util.Random().nextDouble() * 0.2 - 0.1) : motion;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", source.getX()))
.add(new DoubleTag("", source.getY())).add(new DoubleTag("", source.getZ())))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", motion.getX()))
.add(new DoubleTag("", motion.getY())).add(new DoubleTag("", motion.getZ())))
.putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0)).add(new FloatTag("", 0)));
Entity entity = new EntityXPOrb(this.getChunk(source.getFloorX() >> 4, source.getFloorZ() >> 4), nbt);
EntityXPOrb xpOrb = (EntityXPOrb) entity;
xpOrb.setExp(exp);
xpOrb.setPickupDelay(delay);
xpOrb.saveNBT();
xpOrb.spawnToAll();
}
示例3: onUpdate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public int onUpdate(int type) {
if (type == Level.BLOCK_UPDATE_NORMAL) {
Block down = this.down();
if (down.getId() == AIR || down instanceof BlockLiquid) {
EntityFallingBlock fall = (EntityFallingBlock) Entity.createEntity("FallingSand", this.getLevel().getChunk((int) (this.x) >> 4, (int) (this.z) >> 4),
new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", this.x + 0.5))
.add(new DoubleTag("", this.y))
.add(new DoubleTag("", this.z + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
.putInt("TileID", this.getId())
.putByte("Data", this.getDamage()));
fall.spawnToAll();
}
}
return type;
}
示例4: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartTNT minecart = new EntityMinecartTNT(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例5: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartHopper minecart = new EntityMinecartHopper(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例6: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartChest minecart = new EntityMinecartChest(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例7: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartEmpty minecart = new EntityMinecartEmpty(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例8: prime
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public void prime() {
this.getLevel().setBlock(this, new BlockAir(), true);
double mot = (new NukkitRandom()).nextSignedFloat() * Math.PI * 2;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", this.x + 0.5))
.add(new DoubleTag("", this.y))
.add(new DoubleTag("", this.z + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", -Math.sin(mot) * 0.02))
.add(new DoubleTag("", 0.2))
.add(new DoubleTag("", -Math.cos(mot) * 0.02)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
.putByte("Fuse", 80);
Entity tnt = new EntityPrimedTNT(
this.getLevel().getChunk(this.getFloorX() >> 4, this.getFloorZ() >> 4),
nbt
);
tnt.spawnToAll();
this.level.addSound(new TNTPrimeSound(this));
}
示例9: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, int face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartEmpty minecart = new EntityMinecartEmpty(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例10: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, int face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartTNT minecart = new EntityMinecartTNT(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例11: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, int face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartHopper minecart = new EntityMinecartHopper(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例12: onActivate
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public boolean onActivate(Level level, Player player, Block block, Block target, int face, double fx, double fy, double fz) {
Block secret = level.getBlock(block.add(0, -1, 0));
// TODO: 2016/1/30 check if blockId of secret is a rail
EntityMinecartChest minecart = new EntityMinecartChest(
level.getChunk(block.getFloorX() >> 4, block.getFloorZ() >> 4), new CompoundTag("")
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", block.getX() + 0.5))
.add(new DoubleTag("", block.getY()))
.add(new DoubleTag("", block.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)))
);
minecart.spawnToAll();
// TODO: 2016/1/30 if player is survival, item in hand count--
return true;
}
示例13: strikeLighting
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public void strikeLighting(Position pos) {
FullChunk chunk = pos.getLevel().getChunk((int) pos.getX() >> 4, (int) pos.getZ() >> 4);
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos")
.add(new DoubleTag("", pos.getX()))
.add(new DoubleTag("", pos.getY()))
.add(new DoubleTag("", pos.getZ())))
.putList(new ListTag<DoubleTag>("Motion")
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation")
.add(new FloatTag("", 0))
.add(new FloatTag("", 0)));
EntityLightning lightning = new EntityLightning(chunk, nbt);
lightning.spawnToAll();
}
示例14: spawnEntity
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
@Override
public Entity spawnEntity(Location loc, EntityType type) {
try {
BaseFullChunk chunk = nukkit.getChunk(loc.getChunk().getX(), loc.getChunk().getZ());
CompoundTag nbt = new CompoundTag();
nbt.putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", loc.getX() + 0.5))
.add(new DoubleTag("", loc.getY())).add(new DoubleTag("", loc.getZ() + 0.5)))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)).add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0))
.add(new FloatTag("", 0)));
cn.nukkit.entity.Entity ent = cn.nukkit.entity.Entity.createEntity(PokkitEntityTranslator.getEntity(type), chunk, nbt);
ent.spawnToAll();
return PokkitEntity.toBukkit(ent);
} catch(Exception e) {
e.printStackTrace();
}
return null;
}
示例15: strike
import cn.nukkit.nbt.tag.DoubleTag; //导入依赖的package包/类
public LightningStrike strike(Location loc, boolean effect) {
BaseFullChunk chunk = nukkit.getChunk(loc.getChunk().getX(), loc.getChunk().getZ());
int x = loc.getBlockX();
int z = loc.getBlockZ();
int y = loc.getBlockY();
int bId = nukkit.getBlockIdAt(x, y, z);
if (bId != cn.nukkit.block.Block.TALL_GRASS && bId != cn.nukkit.block.Block.WATER)
y += 1;
CompoundTag nbt = new CompoundTag()
.putList(new ListTag<DoubleTag>("Pos").add(new DoubleTag("", x))
.add(new DoubleTag("", y)).add(new DoubleTag("", z)))
.putList(new ListTag<DoubleTag>("Motion").add(new DoubleTag("", 0))
.add(new DoubleTag("", 0)).add(new DoubleTag("", 0)))
.putList(new ListTag<FloatTag>("Rotation").add(new FloatTag("", 0))
.add(new FloatTag("", 0)));
EntityLightning bolt = new EntityLightning(chunk, nbt);
bolt.setEffect(effect);
bolt.spawnToAll();
return PokkitEntityLightningStrike.toBukkit(bolt);
}