Search in sources :

Example 1 with BlockTorch

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

the class StructureAlternateStart method CustomBlockProcessingHandled.

@Override
protected Boolean CustomBlockProcessingHandled(StructureConfiguration configuration, BuildBlock block, World world, BlockPos originalPos, EnumFacing assumedNorth, Block foundBlock, IBlockState blockState, EntityPlayer player) {
    HouseConfiguration houseConfig = (HouseConfiguration) configuration;
    if ((!houseConfig.addBed && foundBlock instanceof BlockBed) || (!houseConfig.addChest && foundBlock instanceof BlockChest) || (!houseConfig.addTorches && foundBlock instanceof BlockTorch) || (!houseConfig.addCraftingTable && (foundBlock instanceof BlockWorkbench || foundBlock instanceof BlockFurnace))) {
        // "handled"
        return true;
    }
    if (foundBlock instanceof BlockFurnace) {
        this.furnacePosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockTrapDoor && houseConfig.addMineShaft) {
        // The trap door will still be added, but the mine shaft may not be
        // built.
        this.trapDoorPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockChest && this.chestPosition == null) {
        this.chestPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    } else if (foundBlock instanceof BlockStandingSign) {
        this.signPosition = block.getStartingPosition().getRelativePosition(originalPos, this.getClearSpace().getShape().getDirection(), configuration.houseFacing);
    }
    if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS.getRegistryName().getResourcePath())) {
        blockState = blockState.withProperty(BlockStainedGlass.COLOR, houseConfig.glassColor);
        block.setBlockState(blockState);
        this.priorityOneBlocks.add(block);
        return true;
    } else if (foundBlock.getRegistryName().getResourceDomain().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourceDomain()) && foundBlock.getRegistryName().getResourcePath().equals(Blocks.STAINED_GLASS_PANE.getRegistryName().getResourcePath())) {
        block.setBlockState(foundBlock.getStateFromMeta(houseConfig.glassColor.getMetadata()));
        this.priorityOneBlocks.add(block);
        return true;
    }
    return false;
}
Also used : BlockFurnace(net.minecraft.block.BlockFurnace) BlockChest(net.minecraft.block.BlockChest) BlockWorkbench(net.minecraft.block.BlockWorkbench) BlockTrapDoor(net.minecraft.block.BlockTrapDoor) BlockStandingSign(net.minecraft.block.BlockStandingSign) BlockBed(net.minecraft.block.BlockBed) HouseConfiguration(com.wuest.prefab.Config.Structures.HouseConfiguration) BlockTorch(net.minecraft.block.BlockTorch)

Example 2 with BlockTorch

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

the class BuildingMethods method SetCeiling.

/**
 * Creates a ceiling (floating floor) in the world.
 * @param world The world to create the floor in.
 * @param pos The block position to start creating the floor.
 * @param block The Type of block to create the floor out of.
 * @param width The width of the floor.
 * @param depth The length of the floor.
 * @param stairs The type of block to create the roof out of.
 * @param configuration The house configuration object. This is specifically used in the basic house.
 * @param houseFacing The direction to start the ceiling.
 * @param itemsToNotAdd The items to not include in the harvested blocks.
 */
public static void SetCeiling(World world, BlockPos pos, Block block, int width, int depth, Block stairs, HouseConfiguration configuration, EnumFacing houseFacing, ArrayList<Item> itemsToNotAdd) {
    // If the ceiling is flat, call SetFloor since it's laid out the same.
    if (configuration.isCeilingFlat) {
        BuildingMethods.SetFloor(world, pos, block, width, depth, new ArrayList<ItemStack>(), houseFacing.getOpposite(), itemsToNotAdd);
        return;
    }
    // Get the stairs state without the facing since it will change.
    IBlockState stateWithoutFacing = stairs.getBlockState().getBaseState().withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.BOTTOM).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.STRAIGHT);
    int wallWidth = configuration.houseWidth;
    int wallDepth = configuration.houseDepth;
    int height = wallWidth / 2;
    boolean isWider = false;
    if (wallWidth > wallDepth) {
        height = wallDepth / 2;
        isWider = true;
    }
    for (int i = 0; i <= height; i++) {
        // I is the vaulted roof level.
        for (int j = 0; j < 4; j++) {
            // Default is depth.
            EnumFacing facing = houseFacing.rotateYCCW();
            EnumFacing flowDirection = houseFacing.getOpposite();
            int wallSize = wallDepth;
            switch(j) {
                case 1:
                    {
                        facing = houseFacing;
                        flowDirection = houseFacing.rotateYCCW();
                        wallSize = wallWidth;
                        break;
                    }
                case 2:
                    {
                        facing = houseFacing.rotateY();
                        flowDirection = houseFacing;
                        wallSize = wallDepth;
                        break;
                    }
                case 3:
                    {
                        facing = houseFacing.getOpposite();
                        flowDirection = houseFacing.rotateY();
                        wallSize = wallWidth;
                        break;
                    }
            }
            for (int k = 0; k <= wallSize; k++) {
                // j is the north/south counter.
                BuildingMethods.ReplaceBlock(world, pos, stateWithoutFacing.withProperty(BlockStairs.FACING, facing));
                pos = pos.offset(flowDirection);
            }
        }
        pos = pos.offset(houseFacing.rotateYCCW()).offset(houseFacing.getOpposite()).up();
        wallWidth = wallWidth - 2;
        wallDepth = wallDepth - 2;
    }
    if (world.isAirBlock(pos.down())) {
        int finalStoneCount = wallDepth;
        if (isWider) {
            finalStoneCount = wallWidth;
        }
        // Add the number of blocks based on the depth/width (minimum 1);
        if (finalStoneCount < 1) {
            finalStoneCount = 1;
        } else {
            finalStoneCount = finalStoneCount + 2;
        }
        BlockPos torchPos = pos;
        for (int i = 0; i < finalStoneCount; i++) {
            BuildingMethods.ReplaceBlock(world, pos, block);
            if (isWider) {
                pos = pos.offset(houseFacing.rotateYCCW());
            } else {
                pos = pos.offset(houseFacing.getOpposite());
            }
        }
        IBlockState torchLocation = world.getBlockState(torchPos);
        if (torchLocation.getBlock().canPlaceTorchOnTop(torchLocation, world, torchPos)) {
            IBlockState blockState = ((BlockTorch) Blocks.TORCH).getStateFromMeta(5);
            BuildingMethods.ReplaceBlock(world, torchPos.up(), blockState);
        }
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack) BlockTorch(net.minecraft.block.BlockTorch)

Aggregations

BlockTorch (net.minecraft.block.BlockTorch)2 HouseConfiguration (com.wuest.prefab.Config.Structures.HouseConfiguration)1 BlockBed (net.minecraft.block.BlockBed)1 BlockChest (net.minecraft.block.BlockChest)1 BlockFurnace (net.minecraft.block.BlockFurnace)1 BlockStandingSign (net.minecraft.block.BlockStandingSign)1 BlockTrapDoor (net.minecraft.block.BlockTrapDoor)1 BlockWorkbench (net.minecraft.block.BlockWorkbench)1 IBlockState (net.minecraft.block.state.IBlockState)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1