Search in sources :

Example 1 with EntityFallingBlock

use of cn.nukkit.entity.item.EntityFallingBlock in project Nukkit by Nukkit.

the class BlockFallable method onUpdate.

public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        Block down = this.down();
        if (down.getId() == AIR || down instanceof BlockLiquid) {
            this.level.setBlock(this, Block.get(Block.AIR), true, true);
            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("", 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());
            EntityFallingBlock fall = new EntityFallingBlock(this.getLevel().getChunk((int) this.x >> 4, (int) this.z >> 4), nbt);
            fall.spawnToAll();
        }
    }
    return type;
}
Also used : EntityFallingBlock(cn.nukkit.entity.item.EntityFallingBlock) FloatTag(cn.nukkit.nbt.tag.FloatTag) EntityFallingBlock(cn.nukkit.entity.item.EntityFallingBlock) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) ListTag(cn.nukkit.nbt.tag.ListTag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

EntityFallingBlock (cn.nukkit.entity.item.EntityFallingBlock)1 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)1 DoubleTag (cn.nukkit.nbt.tag.DoubleTag)1 FloatTag (cn.nukkit.nbt.tag.FloatTag)1 ListTag (cn.nukkit.nbt.tag.ListTag)1