Search in sources :

Example 1 with EntityBoat

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

the class ItemBoat method onActivate.

@Override
public boolean onActivate(Level level, Player player, Block block, Block target, BlockFace face, double fx, double fy, double fz) {
    if (face != BlockFace.UP)
        return false;
    EntityBoat boat = new EntityBoat(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() - 0.0625)).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("", (float) ((player.yaw + 90f) % 360))).add(new FloatTag("", 0))).putByte("woodID", this.getDamage()));
    if (player.isSurvival()) {
        Item item = player.getInventory().getItemInHand();
        item.setCount(item.getCount() - 1);
        player.getInventory().setItemInHand(item);
    }
    boat.spawnToAll();
    return true;
}
Also used : FloatTag(cn.nukkit.nbt.tag.FloatTag) EntityBoat(cn.nukkit.entity.item.EntityBoat) DoubleTag(cn.nukkit.nbt.tag.DoubleTag) ListTag(cn.nukkit.nbt.tag.ListTag) CompoundTag(cn.nukkit.nbt.tag.CompoundTag)

Aggregations

EntityBoat (cn.nukkit.entity.item.EntityBoat)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