Search in sources :

Example 1 with BlockStone

use of net.minecraft.block.BlockStone in project MC-Prefab by Brian-Wuest.

the class StructureAlternateStart method CreateLadderShaft.

private static ArrayList<ItemStack> CreateLadderShaft(World world, BlockPos pos, ArrayList<ItemStack> originalStacks, EnumFacing houseFacing, ArrayList<Item> blocksToNotAdd) {
    int torchCounter = 0;
    // Keep the "west" facing.
    EnumFacing westWall = houseFacing.rotateYCCW();
    // Get the ladder state based on the house facing.
    IBlockState ladderState = Blocks.LADDER.getDefaultState().withProperty(BlockLadder.FACING, houseFacing);
    // Replace the main floor block with air since we don't want it placed in the chest at the end.
    BuildingMethods.ReplaceBlock(world, pos, Blocks.AIR);
    StructureAlternateStart.torchPositions = new ArrayList<BlockPos>();
    while (pos.getY() > 8) {
        IBlockState state = world.getBlockState(pos);
        Block block = state.getBlock();
        torchCounter++;
        // replace them with stone.
        for (int i = 0; i < 4; i++) {
            EnumFacing facing = houseFacing;
            switch(i) {
                case 1:
                    {
                        facing = houseFacing.rotateY();
                        break;
                    }
                case 2:
                    {
                        facing = houseFacing.getOpposite();
                        break;
                    }
                case 3:
                    {
                        facing = houseFacing.rotateYCCW();
                        break;
                    }
                default:
                    {
                        facing = houseFacing;
                    }
            }
            // normal processing.
            if (facing == westWall && torchCounter == 6 && pos.getY() > 14) {
                // First make sure the blocks around this block are stone, then place the torch.
                for (int j = 0; j <= 2; j++) {
                    BlockPos tempPos = null;
                    IBlockState surroundingState = null;
                    Block surroundingBlock = null;
                    if (j == 0) {
                        tempPos = pos.offset(facing, 2);
                        surroundingState = world.getBlockState(tempPos);
                        surroundingBlock = surroundingState.getBlock();
                    } else if (j == 1) {
                        tempPos = pos.offset(facing).offset(facing.rotateY());
                        surroundingState = world.getBlockState(tempPos);
                        surroundingBlock = surroundingState.getBlock();
                    } else {
                        tempPos = pos.offset(facing).offset(facing.rotateYCCW());
                        surroundingState = world.getBlockState(tempPos);
                        surroundingBlock = surroundingState.getBlock();
                    }
                    // Make sure that this is a normal solid block and not a liquid or partial block.
                    if (!(surroundingBlock instanceof BlockStone)) {
                        // This is not a stone block. Get the drops then replace it with stone.
                        originalStacks = BuildingMethods.ConsolidateDrops(surroundingBlock, world, tempPos, surroundingState, originalStacks, blocksToNotAdd);
                        BuildingMethods.ReplaceBlock(world, tempPos, Blocks.STONE);
                    }
                }
                StructureAlternateStart.torchPositions.add(pos.offset(facing));
                torchCounter = 0;
            } else {
                BlockPos tempPos = pos.offset(facing);
                IBlockState surroundingState = world.getBlockState(tempPos);
                Block surroundingBlock = surroundingState.getBlock();
                if (!surroundingBlock.isBlockNormalCube(surroundingState) || surroundingBlock instanceof BlockLiquid) {
                    // This is not a solid block. Get the drops then replace
                    // it with stone.
                    originalStacks = BuildingMethods.ConsolidateDrops(surroundingBlock, world, tempPos, surroundingState, originalStacks, blocksToNotAdd);
                    BuildingMethods.ReplaceBlock(world, tempPos, Blocks.STONE);
                }
            }
        }
        // Get the block drops then replace it with a ladder.
        originalStacks = BuildingMethods.ConsolidateDrops(block, world, pos, state, originalStacks, blocksToNotAdd);
        // Don't place a ladder at this location since it will be destroyed.
        if (pos.getY() >= 10) {
            BuildingMethods.ReplaceBlock(world, pos, ladderState);
        }
        pos = pos.down();
    }
    return originalStacks;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) EnumFacing(net.minecraft.util.EnumFacing) Block(net.minecraft.block.Block) BuildBlock(com.wuest.prefab.StructureGen.BuildBlock) BlockPos(net.minecraft.util.math.BlockPos) BlockStone(net.minecraft.block.BlockStone)

Aggregations

BuildBlock (com.wuest.prefab.StructureGen.BuildBlock)1 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 BlockStone (net.minecraft.block.BlockStone)1 IBlockState (net.minecraft.block.state.IBlockState)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1