net.minecraft.block.state.BlockFaceShape Java Examples

The following examples show how to use net.minecraft.block.state.BlockFaceShape. 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: SurfaceBlockPopulator.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
    if (world.getWorldType() != WorldType.FLAT) {
        int stonesCount = minIndicatorAmount + (minIndicatorAmount >= maxIndicatorAmount ? 0 : random.nextInt(maxIndicatorAmount - minIndicatorAmount));
        for (int i = 0; i < stonesCount; i++) {
            int randomX = chunkX * 16 + random.nextInt(16);
            int randomZ = chunkZ * 16 + random.nextInt(16);
            BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
            topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
            IBlockState blockState = world.getBlockState(topBlockPos);
            if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
                !blockState.isOpaqueCube() || !blockState.isFullBlock())
                continue;
            BlockPos surfaceRockPos = topBlockPos.up();
            world.setBlockState(surfaceRockPos, this.blockState, 16);
        }
    }
}
 
Example #2
Source File: SurfaceRockPopulator.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void populateChunk(World world, int chunkX, int chunkZ, Random random, OreDepositDefinition definition, GridEntryInfo gridEntryInfo) {
    int stonesCount = random.nextInt(2);
    if (world.getWorldType() != WorldType.FLAT && stonesCount > 0) {
        Set<Material> undergroundMaterials = findUndergroundMaterials(gridEntryInfo.getGeneratedBlocks(definition, chunkX, chunkZ));
        if (undergroundMaterials.isEmpty())
            return;

        for (int i = 0; i < stonesCount; i++) {
            int randomX = chunkX * 16 + random.nextInt(16);
            int randomZ = chunkZ * 16 + random.nextInt(16);
            BlockPos topBlockPos = new BlockPos(randomX, 0, randomZ);
            topBlockPos = world.getTopSolidOrLiquidBlock(topBlockPos).down();
            IBlockState blockState = world.getBlockState(topBlockPos);
            if (blockState.getBlockFaceShape(world, topBlockPos, EnumFacing.UP) != BlockFaceShape.SOLID ||
                !blockState.isOpaqueCube() || !blockState.isFullBlock())
                continue;
            BlockPos surfaceRockPos = topBlockPos.up();
            setStoneBlock(world, surfaceRockPos, undergroundMaterials);
        }
    }
}
 
Example #3
Source File: BlockSurfaceRock.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
    if (fromPos.up().equals(pos)) {
        if (worldIn.getBlockState(fromPos).getBlockFaceShape(worldIn, fromPos, EnumFacing.UP) != BlockFaceShape.SOLID) {
            worldIn.destroyBlock(pos, true);
        }
    }
}
 
Example #4
Source File: BlockFrame.java    From GregTech with GNU Lesser General Public License v3.0 5 votes vote down vote up
private boolean canFrameSupportVertical(World worldIn, BlockPos framePos) {
    MutableBlockPos blockPos = new MutableBlockPos(framePos);
    do {
        blockPos.move(EnumFacing.DOWN);
        IBlockState blockState = worldIn.getBlockState(blockPos);
        if (!(blockState.getBlock() instanceof BlockFrame)) {
            return blockState.getBlockFaceShape(worldIn, blockPos, EnumFacing.UP) == BlockFaceShape.SOLID;
        }
    } while (true);
}
 
Example #5
Source File: BlockStorage.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
    if (state.getValue(TYPE).isFullCube())
    {
        return BlockFaceShape.SOLID;
    }
    else
    {
        return BlockFaceShape.UNDEFINED;
    }
}
 
Example #6
Source File: BlockFenceGate.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_)
{
    if (p_193383_4_ != EnumFacing.UP && p_193383_4_ != EnumFacing.DOWN)
    {
        return p_193383_2_.getValue(FACING).getAxis() == p_193383_4_.rotateY().getAxis() ? BlockFaceShape.MIDDLE_POLE : BlockFaceShape.UNDEFINED;
    } else
    {
        return BlockFaceShape.UNDEFINED;
    }
}
 
Example #7
Source File: BlockButton.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
static boolean canPlaceBlock(World worldIn, BlockPos pos, EnumFacing direction)
{
    BlockPos blockpos = pos.offset(direction.getOpposite());
    IBlockState iblockstate = worldIn.getBlockState(blockpos);
    boolean flag = iblockstate.getBlockFaceShape(worldIn, blockpos, direction) == BlockFaceShape.SOLID;
    Block block = iblockstate.getBlock();

    if (direction == EnumFacing.UP)
    {
        return iblockstate.isTopSolid() || !isExceptionBlockForAttaching(block) && flag;
    } else
    {
        return !isExceptBlockForAttachWithPiston(block) && flag;
    }
}
 
Example #8
Source File: BlockWall.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
private boolean canConnectTo(IBlockAccess worldIn, BlockPos pos, EnumFacing p_176253_3_)
{
    IBlockState iblockstate = worldIn.getBlockState(pos);
    Block block = iblockstate.getBlock();
    BlockFaceShape blockfaceshape = iblockstate.getBlockFaceShape(worldIn, pos, p_176253_3_);
    boolean flag = blockfaceshape == BlockFaceShape.MIDDLE_POLE_THICK || blockfaceshape == BlockFaceShape.MIDDLE_POLE && block instanceof net.minecraft.block.BlockFenceGate;
    return !isExcepBlockForAttachWithPiston(block) && blockfaceshape == BlockFaceShape.SOLID || flag;
}
 
Example #9
Source File: BlockFrame.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
protected boolean canBlockStay(World worldIn, BlockPos pos) {
    MutableBlockPos currentPos = new MutableBlockPos(pos);
    currentPos.move(EnumFacing.DOWN);
    IBlockState downState = worldIn.getBlockState(currentPos);
    if (downState.getBlock() instanceof BlockFrame) {
        if (canFrameSupportVertical(worldIn, currentPos)) {
            return true;
        }
    } else if (downState.getBlockFaceShape(worldIn, currentPos, EnumFacing.UP) == BlockFaceShape.SOLID) {
        return true;
    }
    currentPos.move(EnumFacing.UP);
    HashSet<BlockPos> observedSet = new HashSet<>();
    Stack<EnumFacing> moveStack = new Stack<>();
    main:
    while (true) {
        for (EnumFacing facing : EnumFacing.HORIZONTALS) {
            currentPos.move(facing);
            IBlockState blockStateHere = worldIn.getBlockState(currentPos);
            //if there is node, and it can connect with previous node, add it to list, and set previous node as current
            if (blockStateHere.getBlock() instanceof BlockFrame && currentPos.distanceSq(pos) <= SCAFFOLD_PILLAR_RADIUS_SQ && !observedSet.contains(currentPos)) {
                observedSet.add(currentPos.toImmutable());
                currentPos.move(EnumFacing.DOWN);
                downState = worldIn.getBlockState(currentPos);
                if (downState.getBlock() instanceof BlockFrame) {
                    if (canFrameSupportVertical(worldIn, currentPos)) {
                        return true;
                    }
                } else if (downState.getBlockFaceShape(worldIn, currentPos, EnumFacing.UP) == BlockFaceShape.SOLID) {
                    return true;
                }
                currentPos.move(EnumFacing.UP);
                moveStack.push(facing.getOpposite());
                continue main;
            } else currentPos.move(facing.getOpposite());
        }
        if (!moveStack.isEmpty()) {
            currentPos.move(moveStack.pop());
        } else break;
    }
    return false;
}
 
Example #10
Source File: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Retrieves face shape on the current side of this meta tile entity
 */
public BlockFaceShape getFaceShape(EnumFacing side) {
    return isOpaqueCube() ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
}
 
Example #11
Source File: BlockCarpet.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess blockAccess, IBlockState state, BlockPos pos, EnumFacing side)
{
    return side == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
}
 
Example #12
Source File: OpenBlock.java    From OpenModsLib with MIT License 4 votes vote down vote up
public final static boolean isNeighborBlockSolid(IBlockAccess world, BlockPos blockPos, EnumFacing side) {
	final BlockPos pos = blockPos.offset(side);
	final IBlockState state = world.getBlockState(pos);
	return isExceptionBlockForAttaching(state.getBlock()) ||
			state.getBlockFaceShape(world, pos, side.getOpposite()) == BlockFaceShape.SOLID;
}
 
Example #13
Source File: MetaBlock.java    From minecraft-roguelike with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess p_193401_1_, BlockPos p_193401_2_, EnumFacing p_193401_3_) {
	return this.state.getBlockFaceShape(p_193401_1_, p_193401_2_, p_193401_3_);
}
 
Example #14
Source File: BlockBetterChest.java    From BetterChests with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
	return BlockFaceShape.UNDEFINED;
}
 
Example #15
Source File: BlockCrop.java    From AgriCraft with MIT License 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess p_getBlockFaceShape_1_, IBlockState p_getBlockFaceShape_2_, BlockPos p_getBlockFaceShape_3_, EnumFacing p_getBlockFaceShape_4_) {
    // Undefined face shape prevents fence connections.
    return BlockFaceShape.UNDEFINED;
}
 
Example #16
Source File: BlockNetworkRelay.java    From Valkyrien-Skies with Apache License 2.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos,
    EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #17
Source File: BlockButton.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing facing)
{
    return BlockFaceShape.UNDEFINED;
}
 
Example #18
Source File: BlockWall.java    From customstuff4 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess p_193383_1_, IBlockState p_193383_2_, BlockPos p_193383_3_, EnumFacing p_193383_4_)
{
    return p_193383_4_ != EnumFacing.UP && p_193383_4_ != EnumFacing.DOWN ? BlockFaceShape.MIDDLE_POLE_THICK : BlockFaceShape.CENTER_BIG;
}
 
Example #19
Source File: GTBlockBaseConnect.java    From GT-Classic with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
	return BlockFaceShape.UNDEFINED;
}
 
Example #20
Source File: BlockSurfaceRock.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #21
Source File: MetaTileEntity.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
public BlockFaceShape getCoverFaceShape(EnumFacing side) {
    if (getCoverAtSide(side) != null) {
        return BlockFaceShape.SOLID; //covers are always solid
    }
    return getFaceShape(side);
}
 
Example #22
Source File: BlockFoam.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #23
Source File: BlockPipe.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #24
Source File: BlockMachine.java    From GregTech with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    MetaTileEntity metaTileEntity = getMetaTileEntity(worldIn, pos);
    return metaTileEntity == null ? BlockFaceShape.SOLID : metaTileEntity.getCoverFaceShape(face);
}
 
Example #25
Source File: Ladder.java    From EmergingTechnology with MIT License 4 votes vote down vote up
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face)
{
    return BlockFaceShape.UNDEFINED;
}
 
Example #26
Source File: Ladder.java    From EmergingTechnology with MIT License 4 votes vote down vote up
private boolean canAttachTo(World world, BlockPos pos, EnumFacing facing)
{
    IBlockState iblockstate = world.getBlockState(pos);
    boolean flag = isExceptBlockForAttachWithPiston(iblockstate.getBlock());
    return !flag && iblockstate.getBlockFaceShape(world, pos, facing) == BlockFaceShape.SOLID && !iblockstate.canProvidePower();
}
 
Example #27
Source File: BlockAltar.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
	return BlockFaceShape.UNDEFINED;
}
 
Example #28
Source File: BlockKitunebi.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #29
Source File: BlockPlantBamboo.java    From Sakura_mod with MIT License 4 votes vote down vote up
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
    return BlockFaceShape.UNDEFINED;
}
 
Example #30
Source File: BlockCampfire.java    From Sakura_mod with MIT License 4 votes vote down vote up
public boolean canBlockStay(World worldIn, BlockPos pos)
{
    IBlockState downState = worldIn.getBlockState(pos.down());
    return downState.isTopSolid() || downState.getBlockFaceShape(worldIn, pos.down(), EnumFacing.UP) == BlockFaceShape.SOLID;
}