Java Code Examples for cn.nukkit.block.Block#DIAMOND_BLOCK

The following examples show how to use cn.nukkit.block.Block#DIAMOND_BLOCK . 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: BlockEntityBeacon.java    From Jupiter with GNU General Public License v3.0 5 votes vote down vote up
private int calculatePowerLevel() {
    int tileX = getFloorX();
    int tileY = getFloorY();
    int tileZ = getFloorZ();

    //The power level that we're testing for
    for (int powerLevel = 1; powerLevel <= POWER_LEVEL_MAX; powerLevel++) {
        int queryY = tileY - powerLevel; //Layer below the beacon block

        for (int queryX = tileX - powerLevel; queryX <= tileX + powerLevel; queryX++) {
            for (int queryZ = tileZ - powerLevel; queryZ <= tileZ + powerLevel; queryZ++) {

                int testBlockId = level.getBlockIdAt(queryX, queryY, queryZ);
                if (
                        testBlockId != Block.IRON_BLOCK &&
                                testBlockId != Block.GOLD_BLOCK &&
                                testBlockId != Block.EMERALD_BLOCK &&
                                testBlockId != Block.DIAMOND_BLOCK
                        ) {
                    return powerLevel - 1;
                }

            }
        }
    }

    return POWER_LEVEL_MAX;
}
 
Example 2
Source File: BlockEntityBeacon.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int calculatePowerLevel() {
    int tileX = getFloorX();
    int tileY = getFloorY();
    int tileZ = getFloorZ();

    //The power level that we're testing for
    for (int powerLevel = 1; powerLevel <= POWER_LEVEL_MAX; powerLevel++) {
        int queryY = tileY - powerLevel; //Layer below the beacon block

        for (int queryX = tileX - powerLevel; queryX <= tileX + powerLevel; queryX++) {
            for (int queryZ = tileZ - powerLevel; queryZ <= tileZ + powerLevel; queryZ++) {

                int testBlockId = level.getBlockIdAt(queryX, queryY, queryZ);
                if (
                        testBlockId != Block.IRON_BLOCK &&
                                testBlockId != Block.GOLD_BLOCK &&
                                testBlockId != Block.EMERALD_BLOCK &&
                                testBlockId != Block.DIAMOND_BLOCK
                        ) {
                    return powerLevel - 1;
                }

            }
        }
    }

    return POWER_LEVEL_MAX;
}
 
Example 3
Source File: BlockEntityBeacon.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
private int calculatePowerLevel() {
    int tileX = getFloorX();
    int tileY = getFloorY();
    int tileZ = getFloorZ();

    //The power level that we're testing for
    for (int powerLevel = 1; powerLevel <= POWER_LEVEL_MAX; powerLevel++) {
        int queryY = tileY - powerLevel; //Layer below the beacon block

        for (int queryX = tileX - powerLevel; queryX <= tileX + powerLevel; queryX++) {
            for (int queryZ = tileZ - powerLevel; queryZ <= tileZ + powerLevel; queryZ++) {

                int testBlockId = level.getBlockIdAt(queryX, queryY, queryZ);
                if (
                        testBlockId != Block.IRON_BLOCK &&
                                testBlockId != Block.GOLD_BLOCK &&
                                testBlockId != Block.EMERALD_BLOCK &&
                                testBlockId != Block.DIAMOND_BLOCK
                        ) {
                    return powerLevel - 1;
                }

            }
        }
    }

    return POWER_LEVEL_MAX;
}