Java Code Examples for cn.nukkit.math.BlockFace#EAST

The following examples show how to use cn.nukkit.math.BlockFace#EAST . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Entity.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public BlockFace getDirection() {
    double rotation = (this.yaw - 90) % 360;
    if (rotation < 0) {
        rotation += 360.0;
    }
    if ((0 <= rotation && rotation < 45) || (315 <= rotation && rotation < 360)) {
        return BlockFace.NORTH;//s
    } else if (45 <= rotation && rotation < 135) {
        return BlockFace.EAST;//w
    } else if (135 <= rotation && rotation < 225) {
        return BlockFace.SOUTH;//n
    } else if (225 <= rotation && rotation < 315) {
        return BlockFace.WEST;//e
    } else {
        return null;
    }
}
 
Example 2
Source File: BlockVine.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        BlockFace[] faces = {
                BlockFace.DOWN,
                BlockFace.SOUTH,
                BlockFace.WEST,
                BlockFace.DOWN,
                BlockFace.NORTH,
                BlockFace.DOWN,
                BlockFace.DOWN,
                BlockFace.DOWN,
                BlockFace.EAST
        };
        if (!this.getSide(faces[this.meta]).isSolid()) {
            Block up = this.up();
            if (up.getId() != this.getId() || up.meta != this.meta) {
                this.getLevel().useBreakOn(this);
                return Level.BLOCK_UPDATE_NORMAL;
            }
        }
    }
    return 0;
}
 
Example 3
Source File: BlockVine.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        BlockFace[] faces = {
                BlockFace.DOWN,
                BlockFace.SOUTH,
                BlockFace.WEST,
                BlockFace.DOWN,
                BlockFace.NORTH,
                BlockFace.DOWN,
                BlockFace.DOWN,
                BlockFace.DOWN,
                BlockFace.EAST
        };
        if (!this.getSide(faces[this.getDamage()]).isSolid()) {
            Block up = this.up();
            if (up.getId() != this.getId() || up.getDamage() != this.getDamage()) {
                this.getLevel().useBreakOn(this);
                return Level.BLOCK_UPDATE_NORMAL;
            }
        }
    }
    return 0;
}
 
Example 4
Source File: BlockItemFrame.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (this.meta % 8) {
        case 0:
            return BlockFace.WEST;
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
    }

    return null;
}
 
Example 5
Source File: BlockTorch.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing(int meta) {
    switch (meta) {
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.WEST;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.NORTH;
        case 5:
        default:
            return BlockFace.UP;
    }
}
 
Example 6
Source File: BlockTrapdoor.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (this.meta & 3) {
        case 0:
            return BlockFace.NORTH;
        case 1:
            return BlockFace.SOUTH;
        case 2:
            return BlockFace.WEST;
        case 3:
        default:
            return BlockFace.EAST;
    }
}
 
Example 7
Source File: BlockItemFrame.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (this.getDamage() & FACING_BITMASK) {
        case 0:
            return BlockFace.WEST;
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
    }

    return null;
}
 
Example 8
Source File: BlockVine.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private BlockFace getFace() {
    int meta = this.getDamage();
    if ((meta & 1) > 0) {
        return BlockFace.SOUTH;
    } else if ((meta & 2) > 0) {
        return BlockFace.WEST;
    } else if ((meta & 4) > 0) {
        return BlockFace.NORTH;
    } else if ((meta & 8) > 0) {
        return BlockFace.EAST;
    }

    return BlockFace.SOUTH;
}
 
Example 9
Source File: BlockTorch.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getBlockFace(int meta) {
    switch (meta) {
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.WEST;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.NORTH;
        default:
            return BlockFace.UP;
    }
}
 
Example 10
Source File: BlockItemFrame.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing() {
    switch (this.getDamage() % 8) {
        case 0:
            return BlockFace.WEST;
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.NORTH;
        case 3:
            return BlockFace.SOUTH;
    }

    return null;
}
 
Example 11
Source File: BlockTorch.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
public BlockFace getFacing(int meta) {
    switch (meta) {
        case 1:
            return BlockFace.EAST;
        case 2:
            return BlockFace.WEST;
        case 3:
            return BlockFace.SOUTH;
        case 4:
            return BlockFace.NORTH;
        case 5:
        default:
            return BlockFace.UP;
    }
}
 
Example 12
Source File: BlockIterator.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getXFace(Vector3 direction) {
    return ((direction.x) > 0) ? BlockFace.EAST : BlockFace.WEST;
}
 
Example 13
Source File: BlockIterator.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getXFace(Vector3 direction) {
    return ((direction.x) > 0) ? BlockFace.EAST : BlockFace.WEST;
}
 
Example 14
Source File: BlockIterator.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getXFace(Vector3 direction) {
    return ((direction.x) > 0) ? BlockFace.EAST : BlockFace.WEST;
}