Search in sources :

Example 1 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project ImmersiveEngineering by BluSunrize.

the class Utils method canFenceConnectTo.

public static boolean canFenceConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing, Material material) {
    BlockPos other = pos.offset(facing);
    IBlockState state = world.getBlockState(other);
    Block block = world.getBlockState(other).getBlock();
    if (block.canBeConnectedTo(world, other, facing.getOpposite()))
        return true;
    BlockFaceShape blockfaceshape = state.getBlockFaceShape(world, other, facing.getOpposite());
    boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE && (state.getMaterial() == material || block instanceof BlockFenceGate);
    return !isExceptBlockForAttachWithFence(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) DirectionalBlockPos(blusunrize.immersiveengineering.api.DirectionalBlockPos) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 2 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project Almura by AlmuraDev.

the class BlockFaceShapeProcessor method processState.

@Override
public void processState(ConfigurationNode config, final ContentBlock.Builder<ContentBlock, BlockStateDefinition, BlockStateDefinition.Builder<BlockStateDefinition>> builder, final BlockStateDefinition.Builder<BlockStateDefinition> definition) {
    final BlockFaceShape shape = BlockFaceShape.valueOf(config.getString("undefined").toUpperCase().replace(' ', '_'));
    definition.blockFaceShape(shape);
}
Also used : BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 3 with BlockFaceShape

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

the class BlockFakeIceFence 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 4 with BlockFaceShape

use of net.minecraft.block.state.BlockFaceShape in project takumicraft by TNTModders.

the class BlockTakumiFence method canConnectTo.

@Override
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 || block instanceof BlockWall;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockWall(net.minecraft.block.BlockWall) BlockFenceGate(net.minecraft.block.BlockFenceGate) Block(net.minecraft.block.Block) BlockFaceShape(net.minecraft.block.state.BlockFaceShape)

Example 5 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)

Aggregations

BlockFaceShape (net.minecraft.block.state.BlockFaceShape)6 IBlockState (net.minecraft.block.state.IBlockState)5 Block (net.minecraft.block.Block)3 BlockFenceGate (net.minecraft.block.BlockFenceGate)3 DirectionalBlockPos (blusunrize.immersiveengineering.api.DirectionalBlockPos)1 BlockWall (net.minecraft.block.BlockWall)1 TileEntity (net.minecraft.tileentity.TileEntity)1