Search in sources :

Example 6 with BlockFace

use of cn.nukkit.math.BlockFace in project Nukkit by Nukkit.

the class BlockPistonBase method isExtended.

public boolean isExtended() {
    BlockFace face = getFacing();
    Block block = getSide(face);
    return block instanceof BlockPistonHead && ((BlockPistonHead) block).getFacing() == face;
}
Also used : BlockFace(cn.nukkit.math.BlockFace)

Example 7 with BlockFace

use of cn.nukkit.math.BlockFace in project Nukkit by Nukkit.

the class BlockRedstoneDiode method getPowerOnSides.

protected int getPowerOnSides() {
    Vector3 pos = getLocation();
    BlockFace face = getFacing();
    BlockFace face1 = face.rotateY();
    BlockFace face2 = face.rotateYCCW();
    return Math.max(this.getPowerOnSide(pos.getSide(face1), face1), this.getPowerOnSide(pos.getSide(face2), face2));
}
Also used : BlockFace(cn.nukkit.math.BlockFace) Vector3(cn.nukkit.math.Vector3)

Example 8 with BlockFace

use of cn.nukkit.math.BlockFace in project Nukkit by Nukkit.

the class BlockRedstoneTorch method onBreak.

@Override
public boolean onBreak(Item item) {
    this.getLevel().setBlock(this, new BlockAir(), true, true);
    Vector3 pos = getLocation();
    for (BlockFace side : BlockFace.values()) {
        this.level.updateAroundRedstone(pos.getSide(side), null);
    }
    return true;
}
Also used : BlockFace(cn.nukkit.math.BlockFace) Vector3(cn.nukkit.math.Vector3)

Example 9 with BlockFace

use of cn.nukkit.math.BlockFace in project Nukkit by Nukkit.

the class BlockRedstoneTorch method place.

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    Block below = this.down();
    Vector3 pos = getLocation();
    if (!target.isTransparent() && face != BlockFace.DOWN) {
        this.setDamage(getFacing(face.getIndex()).getIndex());
        this.getLevel().setBlock(block, this, true, true);
        for (BlockFace side : BlockFace.values()) {
            this.level.updateAround(pos.getSide(side));
        }
        return true;
    } else if (!below.isTransparent() || below instanceof BlockFence || below.getId() == COBBLE_WALL) {
        this.setDamage(0);
        this.getLevel().setBlock(block, this, true, true);
        for (BlockFace side : BlockFace.values()) {
            this.level.updateAroundRedstone(pos.getSide(side), null);
        }
        return true;
    }
    return false;
}
Also used : BlockFace(cn.nukkit.math.BlockFace) Vector3(cn.nukkit.math.Vector3)

Example 10 with BlockFace

use of cn.nukkit.math.BlockFace in project Nukkit by Nukkit.

the class BlockRedstoneWire method place.

@Override
public boolean place(Item item, Block block, Block target, BlockFace face, double fx, double fy, double fz, Player player) {
    if (face != BlockFace.UP || !canBePlacedOn(target)) {
        return false;
    }
    this.getLevel().setBlock(block, this, true, false);
    this.updateSurroundingRedstone(true);
    Vector3 pos = getLocation();
    for (BlockFace blockFace : Plane.VERTICAL) {
        this.level.updateAroundRedstone(pos.getSide(blockFace), blockFace.getOpposite());
    }
    for (BlockFace blockFace : Plane.VERTICAL) {
        this.updateAround(pos.getSide(blockFace), blockFace.getOpposite());
    }
    for (BlockFace blockFace : Plane.HORIZONTAL) {
        Vector3 v = pos.getSide(blockFace);
        if (this.level.getBlock(v).isNormalBlock()) {
            this.updateAround(v.up(), BlockFace.DOWN);
        } else {
            this.updateAround(v.down(), BlockFace.UP);
        }
    }
    return true;
}
Also used : BlockFace(cn.nukkit.math.BlockFace) Vector3(cn.nukkit.math.Vector3)

Aggregations

BlockFace (cn.nukkit.math.BlockFace)29 Vector3 (cn.nukkit.math.Vector3)16 CompoundTag (cn.nukkit.nbt.tag.CompoundTag)3 BlockRedstoneEvent (cn.nukkit.event.block.BlockRedstoneEvent)2 Player (cn.nukkit.Player)1 Block (cn.nukkit.block.Block)1 BlockAir (cn.nukkit.block.BlockAir)1 BlockLiquid (cn.nukkit.block.BlockLiquid)1 BlockWater (cn.nukkit.block.BlockWater)1 BlockEntity (cn.nukkit.blockentity.BlockEntity)1 BlockEntityChest (cn.nukkit.blockentity.BlockEntityChest)1 BlockEntityHopper (cn.nukkit.blockentity.BlockEntityHopper)1 Entity (cn.nukkit.entity.Entity)1 BlockFromToEvent (cn.nukkit.event.block.BlockFromToEvent)1 PlayerBucketEmptyEvent (cn.nukkit.event.player.PlayerBucketEmptyEvent)1 PlayerBucketFillEvent (cn.nukkit.event.player.PlayerBucketFillEvent)1 Item (cn.nukkit.item.Item)1 ItemTool (cn.nukkit.item.ItemTool)1 Level (cn.nukkit.level.Level)1 Position (cn.nukkit.level.Position)1