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

The following examples show how to use cn.nukkit.math.BlockFace#SOUTH . 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: 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 2
Source File: BlockTripWire.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void updateHook(boolean scheduleUpdate) {
    for (BlockFace side : new BlockFace[]{BlockFace.SOUTH, BlockFace.WEST}) {
        for (int i = 1; i < 42; ++i) {
            Block block = this.getSide(side, i);

            if (block instanceof BlockTripWireHook) {
                BlockTripWireHook hook = (BlockTripWireHook) block;

                if (hook.getFacing() == side.getOpposite()) {
                    hook.calculateState(false, true, i, this);
                }

                /*if(scheduleUpdate) {
                    this.level.scheduleUpdate(hook, 10);
                }*/
                break;
            }

            if (block.getId() != Block.TRIPWIRE) {
                break;
            }
        }
    }
}
 
Example 3
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 4
Source File: BlockTripWire.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void updateHook(boolean scheduleUpdate) {
    for (BlockFace side : new BlockFace[]{BlockFace.SOUTH, BlockFace.WEST}) {
        for (int i = 1; i < 42; ++i) {
            Block block = this.getSide(side, i);

            if (block instanceof BlockTripWireHook) {
                BlockTripWireHook hook = (BlockTripWireHook) block;

                if (hook.getFacing() == side.getOpposite()) {
                    hook.calculateState(false, true, i, this);
                }

                /*if(scheduleUpdate) {
                    this.level.scheduleUpdate(hook, 10);
                }*/
                break;
            }

            if (block.getId() != Block.TRIPWIRE) {
                break;
            }
        }
    }
}
 
Example 5
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 6
Source File: BlockTripWire.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void updateHook(boolean scheduleUpdate) {
    for (BlockFace side : new BlockFace[]{BlockFace.SOUTH, BlockFace.WEST}) {
        for (int i = 1; i < 42; ++i) {
            Block block = this.getSide(side, i);

            if (block instanceof BlockTripWireHook) {
                BlockTripWireHook hook = (BlockTripWireHook) block;

                if (hook.getFacing() == side.getOpposite()) {
                    hook.calculateState(false, true, i, this);
                }

                /*if(scheduleUpdate) {
                    this.level.scheduleUpdate(hook, 10);
                }*/
                break;
            }

            if (block.getId() != Block.TRIPWIRE) {
                break;
            }
        }
    }
}
 
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: 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 9
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 10
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 11
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 12
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 13
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 14
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 15
Source File: BlockIterator.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getZFace(Vector3 direction) {
    return ((direction.z) > 0) ? BlockFace.SOUTH : BlockFace.NORTH;
}
 
Example 16
Source File: BlockIterator.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getZFace(Vector3 direction) {
    return ((direction.z) > 0) ? BlockFace.SOUTH : BlockFace.NORTH;
}
 
Example 17
Source File: BlockIterator.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
private BlockFace getZFace(Vector3 direction) {
    return ((direction.z) > 0) ? BlockFace.SOUTH : BlockFace.NORTH;
}