Search in sources :

Example 6 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project Charset by CharsetMC.

the class LaserBeam method isBlocker.

private final boolean isBlocker(Chunk chunk, BlockPos pos) {
    IBlockState state = chunk.getBlockState(pos);
    // Quickies: air always lets through, opaque cubes never let through. Simple!
    if (state.getBlock().isAir(state, world, pos)) {
        return false;
    }
    if (state.isOpaqueCube()) {
        return true;
    }
    // Check the blacklist
    if (CharsetLaser.BLOCKING_BLOCKS.contains(state.getBlock())) {
        return true;
    }
    // If block is opaque...
    if (state.getLightOpacity(world, pos) >= 192) /* out of 255 */
    {
        // ...and a full cube, nope out
        if (state.isFullCube()) {
            return true;
        }
        // ...and has a blocking shape, nope out
        BlockFaceShape shapeA = state.getBlockFaceShape(world, pos, direction);
        BlockFaceShape shapeB = state.getBlockFaceShape(world, pos, direction.getOpposite());
        if ((shapeA != BlockFaceShape.BOWL && shapeA != BlockFaceShape.UNDEFINED) || (shapeB != BlockFaceShape.BOWL && shapeB != BlockFaceShape.UNDEFINED)) {
            return true;
        }
        return true;
    }
    if (state.getBlock().hasTileEntity(state)) {
        TileEntity tile = chunk.getTileEntity(pos, Chunk.EnumCreateEntityType.IMMEDIATE);
        if (tile != null && tile.hasCapability(CharsetLaser.LASER_RECEIVER, direction.getOpposite())) {
            return true;
        }
    }
    return false;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 7 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project Bewitchment by Um-Mitternacht.

the class BlockScornedBrickFence method canConnectTo.

public boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176524_3_) {
    IBlockState iblockstate = worldIn.getBlockState(pos);
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176524_3_);
    Block block = iblockstate.getBlock();
    boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE && (iblockstate.getMaterial() == this.blockMaterial || block instanceof BlockFenceGate);
    return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 8 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project Lands-of-Icaria by Axanthic-Game-Studios.

the class BlockGem method canPlaceBlockOnSide.

@Override
public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing facing) {
    BlockPos blockpos = pos.offset(facing.getOpposite());
    IBlockState iblockstate = worldIn.getBlockState(blockpos);
    Block block = iblockstate.getBlock();
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, blockpos, facing);
    return !isExceptBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Aggregations

BlockFaceShape (net.minecraft.block.state.BlockFaceShape)8 IBlockState (net.minecraft.block.state.IBlockState)7 Block (net.minecraft.block.Block)5 BlockFenceGate (net.minecraft.block.BlockFenceGate)3 BlockPos (net.minecraft.util.math.BlockPos)2 DirectionalBlockPos (blusunrize.immersiveengineering.api.DirectionalBlockPos)1 BlockWall (net.minecraft.block.BlockWall)1 TileEntity (net.minecraft.tileentity.TileEntity)1