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;
}
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));
}
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;
}
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;
}
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;
}
Aggregations