Search in sources :

Example 6 with Vector3

use of cn.nukkit.math.Vector3 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 7 with Vector3

use of cn.nukkit.math.Vector3 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 8 with Vector3

use of cn.nukkit.math.Vector3 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 9 with Vector3

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

the class BlockRedstoneWire method isPowerSourceAt.

private boolean isPowerSourceAt(BlockFace side) {
    Vector3 pos = getLocation();
    Vector3 v = pos.getSide(side);
    Block block = this.level.getBlock(v);
    boolean flag = block.isNormalBlock();
    boolean flag1 = this.level.getBlock(pos.up()).isNormalBlock();
    return !flag1 && flag && canConnectUpwardsTo(this.level, v.up()) || (canConnectTo(block, side) || !flag && canConnectUpwardsTo(this.level, block.down()));
}
Also used : Vector3(cn.nukkit.math.Vector3)

Example 10 with Vector3

use of cn.nukkit.math.Vector3 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

Vector3 (cn.nukkit.math.Vector3)62 BlockFace (cn.nukkit.math.BlockFace)16 Block (cn.nukkit.block.Block)5 Player (cn.nukkit.Player)3 Entity (cn.nukkit.entity.Entity)3 BlockIgniteEvent (cn.nukkit.event.block.BlockIgniteEvent)3 Random (java.util.Random)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 EntityLiving (cn.nukkit.entity.EntityLiving)2 BlockRedstoneEvent (cn.nukkit.event.block.BlockRedstoneEvent)2 BlockSpreadEvent (cn.nukkit.event.block.BlockSpreadEvent)2 VehicleMoveEvent (cn.nukkit.event.vehicle.VehicleMoveEvent)2 VehicleUpdateEvent (cn.nukkit.event.vehicle.VehicleUpdateEvent)2 ItemBlock (cn.nukkit.item.ItemBlock)2 TranslationContainer (cn.nukkit.lang.TranslationContainer)2 Level (cn.nukkit.level.Level)2 Location (cn.nukkit.level.Location)2 AxisAlignedBB (cn.nukkit.math.AxisAlignedBB)2 NukkitRandom (cn.nukkit.math.NukkitRandom)2 Rail (cn.nukkit.utils.Rail)2