Java Code Examples for cn.nukkit.block.Block#isNormalBlock()

The following examples show how to use cn.nukkit.block.Block#isNormalBlock() . 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: EntityMinecartAbstract.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the minecart display block!
 *
 * @param block The block that will changed. Set {@code null} for BlockAir
 * @return {@code true} if the block is normal block
 */
public boolean setDisplayBlock(Block block) {
    if (block != null) {
        if (block.isNormalBlock()) {
            blockInside = block;
            int display = blockInside.getId()
                    | blockInside.getDamage() << 16;
            setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 1));
            setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, display));
            setDisplayBlockOffset(6);
        }
    } else {
        // Set block to air (default).
        blockInside = null;
        setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 0));
        setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, 0));
        setDisplayBlockOffset(0);
    }
    return true;
}
 
Example 2
Source File: Level.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public void updateComparatorOutputLevel(Vector3 v) {
    for (BlockFace face : Plane.HORIZONTAL) {
        Vector3 pos = v.getSide(face);

        if (this.isChunkLoaded((int) pos.x >> 4, (int) pos.z >> 4)) {
            Block block1 = this.getBlock(pos);

            if (BlockRedstoneDiode.isDiode(block1)) {
                block1.onUpdate(BLOCK_UPDATE_REDSTONE);
            } else if (block1.isNormalBlock()) {
                pos = pos.getSide(face);
                block1 = this.getBlock(pos);

                if (BlockRedstoneDiode.isDiode(block1)) {
                    block1.onUpdate(BLOCK_UPDATE_REDSTONE);
                }
            }
        }
    }
}
 
Example 3
Source File: Level.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void updateComparatorOutputLevel(Vector3 v) {
    for (BlockFace face : Plane.HORIZONTAL) {
        Vector3 pos = v.getSide(face);

        if (this.isChunkLoaded((int) pos.x >> 4, (int) pos.z >> 4)) {
            Block block1 = this.getBlock(pos);

            if (BlockRedstoneDiode.isDiode(block1)) {
                block1.onUpdate(BLOCK_UPDATE_REDSTONE);
            } else if (block1.isNormalBlock()) {
                pos = pos.getSide(face);
                block1 = this.getBlock(pos);

                if (BlockRedstoneDiode.isDiode(block1)) {
                    block1.onUpdate(BLOCK_UPDATE_REDSTONE);
                }
            }
        }
    }
}
 
Example 4
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Set the minecart display block!
 *
 * @param block The block that will changed. Set {@code null} for BlockAir
 * @return {@code true} if the block is normal block
 */
@API(usage = Usage.MAINTAINED, definition = Definition.UNIVERSAL)
public boolean setDisplayBlock(Block block) {
    if (block != null) {
        if (block.isNormalBlock()) {
            blockInside = block;
            int display = blockInside.getId()
                    | blockInside.getDamage() << 16;
            setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 1));
            setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, display));
            setDisplayBlockOffset(6);
        }
    } else {
        // Set block to air (default).
        blockInside = null;
        setDataProperty(new ByteEntityData(DATA_MINECART_HAS_DISPLAY, 0));
        setDataProperty(new IntEntityData(DATA_MINECART_DISPLAY_BLOCK, 0));
        setDisplayBlockOffset(0);
    }
    return true;
}
 
Example 5
Source File: Level.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public void updateComparatorOutputLevel(Vector3 v) {
    for (BlockFace face : Plane.HORIZONTAL) {
        Vector3 pos = v.getSide(face);

        if (this.isChunkLoaded((int) pos.x >> 4, (int) pos.z >> 4)) {
            Block block1 = this.getBlock(pos);

            if (BlockRedstoneDiode.isDiode(block1)) {
                block1.onUpdate(BLOCK_UPDATE_REDSTONE);
            } else if (block1.isNormalBlock()) {
                pos = pos.getSide(face);
                block1 = this.getBlock(pos);

                if (BlockRedstoneDiode.isDiode(block1)) {
                    block1.onUpdate(BLOCK_UPDATE_REDSTONE);
                }
            }
        }
    }
}
 
Example 6
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Set the minecart display block
 *
 * @param block The block that will changed. Set {@code null} for BlockAir
 * @param update Do update for the block. (This state changes if you want to show the block)
 * @return {@code true} if the block is normal block
 */
@API(usage = Usage.MAINTAINED, definition = Definition.UNIVERSAL)
public boolean setDisplayBlock(Block block, boolean update) {
    if(!update){
        if (block.isNormalBlock()) {
            blockInside = block;
        } else {
            blockInside = null;
        }
        return true;
    }
    if (block != null) {
        if (block.isNormalBlock()) {
            blockInside = block;
            int display = blockInside.getId()
                    | blockInside.getDamage() << 16;
            setDataProperty(new ByteEntityData(DATA_HAS_DISPLAY, 1));
            setDataProperty(new IntEntityData(DATA_DISPLAY_ITEM, display));
            setDisplayBlockOffset(6);
        }
    } else {
        // Set block to air (default).
        blockInside = null;
        setDataProperty(new ByteEntityData(DATA_HAS_DISPLAY, 0));
        setDataProperty(new IntEntityData(DATA_DISPLAY_ITEM, 0));
        setDisplayBlockOffset(0);
    }
    return true;
}
 
Example 7
Source File: Level.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public int getRedstonePower(Vector3 pos, BlockFace face) {
    Block block = this.getBlock(pos);
    return block.isNormalBlock() ? this.getStrongPower(pos) : block.getWeakPower(face);
}
 
Example 8
Source File: Level.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public int getRedstonePower(Vector3 pos, BlockFace face) {
    Block block = this.getBlock(pos);
    return block.isNormalBlock() ? this.getStrongPower(pos) : block.getWeakPower(face);
}
 
Example 9
Source File: Level.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public int getRedstonePower(Vector3 pos, BlockFace face) {
    Block block = this.getBlock(pos);
    return block.isNormalBlock() ? this.getStrongPower(pos) : block.getWeakPower(face);
}