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;
}
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);
}
}
}
Aggregations