Java Code Examples for net.minecraft.block.state.IBlockState#isSideSolid()

The following examples show how to use net.minecraft.block.state.IBlockState#isSideSolid() . 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: ItemBackpack.java    From WearableBackpacks with MIT License 6 votes vote down vote up
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand,
                                  EnumFacing facing, float hitX, float hitY, float hitZ) {
	IBlockState state = worldIn.getBlockState(pos);
	// If the block is replaceable, keep the placing position
	// the same but check the block below for solidity.
	if (state.getBlock().isReplaceable(worldIn, pos))
		state = worldIn.getBlockState(pos.offset(EnumFacing.DOWN));
	// Otherwise make sure the top side is used, and
	// change the placing position to the block above.
	else if (facing == EnumFacing.UP)
		pos = pos.offset(EnumFacing.UP);
	else return EnumActionResult.FAIL;
	
	// Check if the side is solid and try to place the backpack.
	return (state.isSideSolid(worldIn, pos, EnumFacing.UP) &&
	        BackpackHelper.placeBackpack(worldIn, pos, player.getHeldItem(hand), player, false))
		? EnumActionResult.SUCCESS : EnumActionResult.FAIL;
}
 
Example 2
Source File: BlockWindBell.java    From Sakura_mod with MIT License 4 votes vote down vote up
public boolean canBlockStay(World worldIn, BlockPos pos) {
    IBlockState state = worldIn.getBlockState(pos.up());
    return !worldIn.isAirBlock(pos.up())&&state.isSideSolid(worldIn, pos.up(), EnumFacing.DOWN);
}
 
Example 3
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 4 votes vote down vote up
private BlockPos checkReplacePositionIgnoringSide(World world, BlockPos posIn, EnumFacing side, BlockPos posMin, BlockPos posMax,
        Set<BlockPos> visited, List<BlockPos> branches, List<BlockPosStateDist> positions, boolean diagonals, BlockInfo biTarget, BlockInfo biBound)
{
    BlockPos pos = posIn;
    BlockPos continueTo = null;
    int sides = 0;

    if (visited.contains(pos) || PositionUtils.isPositionInsideArea(pos, posMin, posMax) == false)
    {
        return null;
    }

    IBlockState state = world.getBlockState(pos);

    // The block must be identical to the original targeted block
    if (state == biTarget.blockState)
    {
        BlockPos posAdj = pos.offset(side);
        IBlockState stateAdj = world.getBlockState(posAdj);
        Block blockAdj = stateAdj.getBlock();

        // The block must have a non-full block on the front face to be valid for replacing
        if (blockAdj.isAir(stateAdj, world, posAdj) || stateAdj.isSideSolid(world, posAdj, side.getOpposite()) == false)
        {
            positions.add(new BlockPosStateDist(posIn, world.provider.getDimension(), side, biBound));
        }
        else
        {
            return null;
        }
    }
    else
    {
        return null;
    }

    visited.add(pos);

    for (BlockPos posTmp : PositionUtils.getAdjacentPositions(pos, side, diagonals))
    {
        if (visited.contains(posTmp) || PositionUtils.isPositionInsideArea(posTmp, posMin, posMax) == false)
        {
            continue;
        }

        if (world.getBlockState(posTmp) == biTarget.blockState)
        {
            if (visited.contains(posTmp) == false)
            {
                if (sides == 0)
                {
                    continueTo = posTmp;
                }
                else if (branches.contains(posTmp) == false)
                {
                    branches.add(posTmp);
                }
            }

            sides++;
        }
    }

    return continueTo;
}