net.minecraft.block.BlockStairs Java Examples

The following examples show how to use net.minecraft.block.BlockStairs. 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: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 6 votes vote down vote up
protected IBlockState getBiomeSpecificBlockState(IBlockState blockstateIn) {
    net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID event = new net.minecraftforge.event.terraingen.BiomeEvent.GetVillageBlockID(startPiece == null ? null : startPiece.biome, blockstateIn);
    net.minecraftforge.common.MinecraftForge.TERRAIN_GEN_BUS.post(event);

    if (event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.DENY)
        return event.getReplacement();
    if (event.getBiome() == TofuBiomes.ZUNDATOFU_PLAINS) {

        if (blockstateIn.getBlock() == BlockLoader.SOYMILK) {
            return BlockLoader.ZUNDASOYMILK.getDefaultState();
        }

        if (blockstateIn.getBlock() == BlockLoader.TOFUISHI_BRICK) {
            return BlockLoader.TOFUZUNDA_BRICK.getDefaultState();
        }

        if (blockstateIn.getBlock() == BlockLoader.TOFUMOMEN_STAIRS) {
            return BlockLoader.TOFUZUNDA_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, blockstateIn.getValue(BlockStairs.FACING));
        }

    }

    return blockstateIn;
}
 
Example #2
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
private static AxisAlignedBB getCollQuarterBlock(IBlockState bstate)
{
	boolean flag = bstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;

	switch ((EnumFacing)bstate.getValue(BlockStairs.FACING))
	{
	case NORTH:
	default:
		return flag ? AABB_QTR_BOT_NORTH : AABB_QTR_TOP_NORTH;
	case SOUTH:
		return flag ? AABB_QTR_BOT_SOUTH : AABB_QTR_TOP_SOUTH;
	case WEST:
		return flag ? AABB_QTR_BOT_WEST : AABB_QTR_TOP_WEST;
	case EAST:
		return flag ? AABB_QTR_BOT_EAST : AABB_QTR_TOP_EAST;
	}
}
 
Example #3
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
private static List<AxisAlignedBB> getCollisionBoxList(IBlockState bstate)
{
	List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
	boolean flag = bstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;
	list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM);
	BlockStairs.EnumShape blockstairs$enumshape = (BlockStairs.EnumShape)bstate.getValue(BlockStairs.SHAPE);

	if (blockstairs$enumshape == BlockStairs.EnumShape.STRAIGHT || blockstairs$enumshape == BlockStairs.EnumShape.INNER_LEFT || blockstairs$enumshape == BlockStairs.EnumShape.INNER_RIGHT)
	{
		list.add(getCollQuarterBlock(bstate));
	}

	if (blockstairs$enumshape != BlockStairs.EnumShape.STRAIGHT)
	{
		list.add(getCollEighthBlock(bstate));
	}

	return list;
}
 
Example #4
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
{
	if (net.minecraftforge.common.ForgeModContainer.disableStairSlabCulling)
		return super.doesSideBlockRendering(state, world, pos, face);

	if ( state.isOpaqueCube() )
		return true;

	state = this.getActualState(state, world, pos);

	EnumHalf half = state.getValue(BlockStairs.HALF);
	EnumFacing side = state.getValue(BlockStairs.FACING);
	EnumShape shape = state.getValue(BlockStairs.SHAPE);
	if (face == EnumFacing.UP) return half == EnumHalf.TOP;
	if (face == EnumFacing.DOWN) return half == EnumHalf.BOTTOM;
	if (shape == EnumShape.OUTER_LEFT || shape == EnumShape.OUTER_RIGHT) return false;
	if (face == side) return true;
	if (shape == EnumShape.INNER_LEFT && face.rotateY() == side) return true;
	if (shape == EnumShape.INNER_RIGHT && face.rotateYCCW() == side) return true;
	return false;
}
 
Example #5
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean isSideSolid(IBlockState state,IBlockAccess world, BlockPos pos, EnumFacing side)
{
	boolean flipped = state.getValue(BlockStairs.HALF) == EnumHalf.TOP;
	EnumShape shape = (EnumShape)state.getValue(BlockStairs.SHAPE);
	EnumFacing facing = (EnumFacing)state.getValue(BlockStairs.FACING);
	if (side == EnumFacing.UP) return flipped;
	if (side == EnumFacing.DOWN) return !flipped;
	if (facing == side) return true;
	if (flipped)
	{
		if (shape == EnumShape.INNER_LEFT) return side == facing.rotateYCCW();
		if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateY();
	}
	else
	{
		if (shape == EnumShape.INNER_LEFT) return side == facing.rotateY();
		if (shape == EnumShape.INNER_RIGHT) return side == facing.rotateYCCW();
	}
	return false;
}
 
Example #6
Source File: MetaStair.java    From minecraft-roguelike with GNU General Public License v3.0 5 votes vote down vote up
public MetaStair setOrientation(Cardinal dir, Boolean upsideDown){
	IBlockState stair = this.getBlock().getDefaultState();
	stair = stair.withProperty(BlockStairs.FACING, Cardinal.facing(dir));
	stair = stair.withProperty(BlockStairs.HALF, upsideDown ? EnumHalf.TOP : EnumHalf.BOTTOM);
	this.setState(stair);
	return this;
}
 
Example #7
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public int getMetaFromState(IBlockState state)
{
	int i = 0;

	if (state.getValue(BlockStairs.HALF) == EnumHalf.TOP)
	{
		i |= 0x4;
	}

	i |= 5 - ((EnumFacing)state.getValue(BlockStairs.FACING)).getIndex();
	return i;
}
 
Example #8
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getStateFromMeta(int meta)
{
	IBlockState iblockstate = getDefaultState().withProperty(BlockStairs.HALF, (meta & 0x4) > 0 ? EnumHalf.TOP : EnumHalf.BOTTOM);
	iblockstate = iblockstate.withProperty(BlockStairs.FACING, EnumFacing.getFront(5 - (meta & 0x3)));
	return iblockstate;
}
 
Example #9
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
private static BlockStairs.EnumShape func_185706_d(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
	EnumFacing enumfacing = (EnumFacing)p_185706_0_.getValue(BlockStairs.FACING);
	IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));

	if (isBlockStairs(iblockstate) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate.getValue(BlockStairs.HALF))
	{
		EnumFacing enumfacing1 = (EnumFacing)iblockstate.getValue(BlockStairs.FACING);

		if (enumfacing1.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing1.getOpposite()))
		{
			if (enumfacing1 == enumfacing.rotateYCCW())
			{
				return BlockStairs.EnumShape.OUTER_LEFT;
			}

			return BlockStairs.EnumShape.OUTER_RIGHT;
		}
	}

	IBlockState iblockstate1 = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing.getOpposite()));

	if (isBlockStairs(iblockstate1) && p_185706_0_.getValue(BlockStairs.HALF) == iblockstate1.getValue(BlockStairs.HALF))
	{
		EnumFacing enumfacing2 = (EnumFacing)iblockstate1.getValue(BlockStairs.FACING);

		if (enumfacing2.getAxis() != ((EnumFacing)p_185706_0_.getValue(BlockStairs.FACING)).getAxis() && isDifferentStairs(p_185706_0_, p_185706_1_, p_185706_2_, enumfacing2))
		{
			if (enumfacing2 == enumfacing.rotateYCCW())
			{
				return BlockStairs.EnumShape.INNER_LEFT;
			}

			return BlockStairs.EnumShape.INNER_RIGHT;
		}
	}

	return BlockStairs.EnumShape.STRAIGHT;
}
 
Example #10
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
{
	IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
	iblockstate = iblockstate.withProperty(BlockStairs.FACING, placer.getHorizontalFacing()).withProperty(BlockStairs.SHAPE, EnumShape.STRAIGHT);
	return (facing != EnumFacing.DOWN) && ((facing == EnumFacing.UP) || (hitY <= 0.5D)) ? iblockstate.withProperty(BlockStairs.HALF, EnumHalf.BOTTOM) : iblockstate.withProperty(BlockStairs.HALF, EnumHalf.TOP);
}
 
Example #11
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a bounding box representing an eighth of a block (a block whose three dimensions are halved).
 * Used in all stair shapes except STRAIGHT (gets added alone in the case of OUTER; alone with a quarter block in
 * case of INSIDE).
 */
private static AxisAlignedBB getCollEighthBlock(IBlockState bstate)
{
	EnumFacing enumfacing = (EnumFacing)bstate.getValue(BlockStairs.FACING);
	EnumFacing enumfacing1;

	switch ((BlockStairs.EnumShape)bstate.getValue(BlockStairs.SHAPE))
	{
	case OUTER_LEFT:
	default:
		enumfacing1 = enumfacing;
		break;
	case OUTER_RIGHT:
		enumfacing1 = enumfacing.rotateY();
		break;
	case INNER_RIGHT:
		enumfacing1 = enumfacing.getOpposite();
		break;
	case INNER_LEFT:
		enumfacing1 = enumfacing.rotateYCCW();
	}

	boolean flag = bstate.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;

	switch (enumfacing1)
	{
	case NORTH:
	default:
		return flag ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW;
	case SOUTH:
		return flag ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE;
	case WEST:
		return flag ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW;
	case EAST:
		return flag ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE;
	}
}
 
Example #12
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public void setBaseCollisionBounds(IBlockAccess worldIn, BlockPos pos)
{
	if (worldIn.getBlockState(pos).getValue(BlockStairs.HALF) == EnumHalf.TOP)
	{
		setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);
	}
	else
	{
		setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
	}
}
 
Example #13
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @return Can this block attach to other blocks for support checks in this direction
 */
@Override
public boolean canSupportFacing(IBlockState myState, IBlockAccess world, BlockPos pos, EnumFacing facing)
{
	EnumFacing f = (EnumFacing)myState.getValue(BlockStairs.FACING);
	if(facing == f.rotateY() || facing == f.rotateYCCW())
		return true;

	return myState.getBlock().isSideSolid(myState, world, pos, facing);
}
 
Example #14
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 5 votes vote down vote up
public BlockStairsTFC(IBlockState modelState)
{
	super(modelState.getBlock().getMaterial(modelState), null);
	setDefaultState(this.blockState.getBaseState().withProperty(BlockStairs.FACING, EnumFacing.NORTH).withProperty(BlockStairs.HALF, EnumHalf.BOTTOM).withProperty(BlockStairs.SHAPE, EnumShape.STRAIGHT));
	this.modelBlock = modelState.getBlock();
	this.modelState = modelState;
	//setHardness(this.modelBlock.blockHardness);
	//setResistance(this.modelBlock.blockResistance / 3.0F);
	this.setSoundType(SoundType.WOOD);
	setLightOpacity(255);
	this.setCreativeTab(TFCTabs.TFCBuilding);
}
 
Example #15
Source File: IStructure.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Will return a list of blocks that are incorrect. If this list is empty, the structure is complete.
 */
default Set<BlockPos> testStructure(World world, BlockPos pos) {
	Set<BlockPos> errors = new HashSet<>();

	for (Template.BlockInfo info : getStructure().blockInfos()) {
		if (info.blockState == null) continue;
		if (info.blockState.getMaterial() == Material.AIR || info.blockState.getBlock() == Blocks.STRUCTURE_VOID)
			continue;

		BlockPos realPos = info.pos.add(pos).subtract(getStructure().getOrigin());
		IBlockState state = world.getBlockState(realPos);
		if (state != info.blockState) {

			if (state.getBlock() == ModBlocks.CREATIVE_MANA_BATTERY && info.blockState.getBlock() == ModBlocks.MANA_BATTERY) {
				continue;
			}

			if (info.blockState.getBlock() instanceof BlockStairs && state.getBlock() instanceof BlockStairs
					&& info.blockState.getBlock() == state.getBlock()
					&& info.blockState.getValue(BlockStairs.HALF) == state.getValue(BlockStairs.HALF)
					&& info.blockState.getValue(BlockStairs.SHAPE) == state.getValue(BlockStairs.SHAPE)) {
				if (info.blockState.getValue(BlockStairs.FACING) != state.getValue(BlockStairs.FACING))
					world.setBlockState(realPos, info.blockState);
				continue;
			}
			errors.add(realPos);
		}
	}
	return errors;
}
 
Example #16
Source File: EasyPlaceUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private static Vec3d applyCarpetProtocolHitVec(BlockPos pos, IBlockState state, Vec3d hitVecIn)
{
    double x = hitVecIn.x;
    double y = hitVecIn.y;
    double z = hitVecIn.z;
    Block block = state.getBlock();
    EnumFacing facing = fi.dy.masa.malilib.util.BlockUtils.getFirstPropertyFacingValue(state);

    if (facing != null)
    {
        x = facing.ordinal() + 2 + pos.getX();
    }

    if (block instanceof BlockRedstoneRepeater)
    {
        x += ((state.getValue(BlockRedstoneRepeater.DELAY)) - 1) * 10;
    }
    else if (block instanceof BlockTrapDoor && state.getValue(BlockTrapDoor.HALF) == BlockTrapDoor.DoorHalf.TOP)
    {
        x += 10;
    }
    else if (block instanceof BlockRedstoneComparator && state.getValue(BlockRedstoneComparator.MODE) == BlockRedstoneComparator.Mode.SUBTRACT)
    {
        x += 10;
    }
    else if (block instanceof BlockStairs && state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP)
    {
        x += 10;
    }

    return new Vec3d(x, y, z);
}
 
Example #17
Source File: BlockTofuStairs.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public BlockTofuStairs(IBlockState state)
{
    super(state);
    this.setCreativeTab(CommonProxy.tab);
    this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HALF, BlockStairs.EnumHalf.BOTTOM).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT));

    this.useNeighborBrightness = true;
}
 
Example #18
Source File: BlockMapBuilder.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private boolean blockIsRepeatable(IBlockState block) {
	return !(block instanceof BlockStairs || block instanceof BlockDoor);
}
 
Example #19
Source File: BastionsLairEntranceGenerator.java    From ToroQuest with GNU General Public License v3.0 4 votes vote down vote up
private IBlockState getStairBlock() {

		BlockStairs stairsBlock = (BlockStairs) Blocks.STONE_BRICK_STAIRS;

		if (y > surface) {
			return Blocks.AIR.getDefaultState();
		}

		if (y < 1) {
			return Blocks.STONE.getDefaultState();
		}

		if (x == 0 && z == 0) {
			return Blocks.STONE.getDefaultState();
		}

		int yAdj = (y + 1) % 4;

		switch (yAdj) {
		case 0:
			if (x == 1 && z == 0) {
				return stairsBlock.getStateFromMeta(2);
			}
			if (x == 1 && z == 1) {
				return Blocks.STONEBRICK.getDefaultState();
			}
			break;
		case 1:
			if (x == 0 && z == 1) {
				return stairsBlock.getStateFromMeta(1);
			}
			if (x == -1 && z == 1) {
				return Blocks.STONEBRICK.getDefaultState();
			}
			break;
		case 2:
			if (x == -1 && z == 0) {
				return stairsBlock.getStateFromMeta(3);
			}
			if (x == -1 && z == -1) {
				return Blocks.STONEBRICK.getDefaultState();
			}
			break;
		case 3:
			if (x == 0 && z == -1) {
				return stairsBlock.getStateFromMeta(0);
			}
			if (x == 1 && z == -1) {
				return Blocks.STONEBRICK.getDefaultState();
			}
			break;
		default:
			break;
		}
		return Blocks.AIR.getDefaultState();
	}
 
Example #20
Source File: BlockWisdomWoodStairs.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isTopSolid(IBlockState state) {
	return state.getValue(HALF) == BlockStairs.EnumHalf.TOP;
}
 
Example #21
Source File: BlockTofuStairs.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public BlockStairs setFragile()
{
    isFragile = true;
    this.setTickRandomly(true);
    return this;
}
 
Example #22
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 6 - 1, 0);
    }

    IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.tofuTerrain.getDefaultState());
    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
    IBlockState iblockstate3 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 4, 0, 4, iblockstate, iblockstate, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 4, 0, 4, 4, 4, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 1, 3, 4, 3, iblockstate1, iblockstate1, false);
    this.setBlockState(worldIn, iblockstate, 0, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 1, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 0, 3, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 1, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate, 4, 3, 4, structureBoundingBoxIn);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 1, 0, 3, 3, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 4, 1, 1, 4, 3, 3, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 4, 3, 3, 4, iblockstate1, iblockstate1, false);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 2, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 2, 2, 4, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 4, 2, 2, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 1, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 1, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 2, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 3, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 2, 0, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate1, 3, 1, 0, structureBoundingBoxIn);

    if (this.getBlockStateFromPos(worldIn, 2, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 2, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR)
    {
        this.setBlockState(worldIn, iblockstate2, 2, 0, -1, structureBoundingBoxIn);

    }

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 3, 3, 3, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);


    this.placeTorch(worldIn, EnumFacing.NORTH, 2, 3, 1, structureBoundingBoxIn);
    this.placeDoor(worldIn, structureBoundingBoxIn, randomIn, 2, 1, 0, EnumFacing.NORTH);

    for (int j = 0; j < 5; ++j)
    {
        for (int i = 0; i < 5; ++i)
        {
            this.clearCurrentPositionBlocksUpwards(worldIn, i, 6, j, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate, i, -1, j, structureBoundingBoxIn);
        }
    }

    this.spawnVillagers(worldIn, structureBoundingBoxIn, 1, 1, 2, 1);
    return true;
}
 
Example #23
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
private static boolean isDifferentStairs(IBlockState p_185704_0_, IBlockAccess p_185704_1_, BlockPos p_185704_2_, EnumFacing p_185704_3_)
{
	IBlockState iblockstate = p_185704_1_.getBlockState(p_185704_2_.offset(p_185704_3_));
	return !isBlockStairs(iblockstate) || iblockstate.getValue(BlockStairs.FACING) != p_185704_0_.getValue(BlockStairs.FACING) || iblockstate.getValue(BlockStairs.HALF) != p_185704_0_.getValue(BlockStairs.HALF);
}
 
Example #24
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
public static boolean isBlockStairs(IBlockState p_185709_0_)
{
	return p_185709_0_.getBlock() instanceof BlockStairs || p_185709_0_.getBlock() instanceof BlockStairsTFC;
}
 
Example #25
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
         * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
         * Mineshafts at the end, it adds Fences...
         */
        public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
            if (this.averageGroundLvl < 0) {
                this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

                if (this.averageGroundLvl < 0) {
                    return true;
                }

                this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 6 - 1, 0);
            }

            IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.tofuTerrain.getDefaultState());
            IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
            IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
            IBlockState iblockstate3 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
            IBlockState iblockstate4 = this.getBiomeSpecificBlockState(Blocks.OAK_FENCE.getDefaultState());
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 3, 5, 4, Blocks.AIR.getDefaultState(), Blocks.AIR.getDefaultState(), false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 3, 0, 4, iblockstate, iblockstate, false);
            if (this.isTallHouse) {
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 4, 1, 2, 4, 3, iblockstate3, iblockstate3, false);
            } else {
                this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 5, 1, 2, 5, 3, iblockstate3, iblockstate3, false);
            }

            this.setBlockState(worldIn, iblockstate3, 1, 4, 0, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 2, 4, 0, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 1, 4, 4, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 2, 4, 4, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 0, 4, 1, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 0, 4, 2, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 0, 4, 3, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 3, 4, 1, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 3, 4, 2, structureBoundingBoxIn);
            this.setBlockState(worldIn, iblockstate3, 3, 4, 3, structureBoundingBoxIn);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 0, 0, 3, 0, iblockstate3, iblockstate3, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 1, 0, 3, 3, 0, iblockstate3, iblockstate3, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 4, 0, 3, 4, iblockstate3, iblockstate3, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 1, 4, 3, 3, 4, iblockstate3, iblockstate3, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 1, 1, 0, 3, 3, iblockstate1, iblockstate1, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 3, 1, 1, 3, 3, 3, iblockstate1, iblockstate1, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 0, 2, 3, 0, iblockstate1, iblockstate1, false);
            this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 4, 2, 3, 4, iblockstate1, iblockstate1, false);
/*            this.setBlockState(worldIn, Blocks.STAINED_GLASS_PANE.getDefaultState().withProperty(BlockStainedGlassPane.COLOR, EnumDyeColor.LIGHT_BLUE), 0, 2, 2, structureBoundingBoxIn);
            this.setBlockState(worldIn, Blocks.STAINED_GLASS_PANE.getDefaultState().withProperty(BlockStainedGlassPane.COLOR, EnumDyeColor.LIGHT_BLUE), 3, 2, 2, structureBoundingBoxIn);*/

            if (this.tablePosition > 0) {
                this.setBlockState(worldIn, iblockstate4, this.tablePosition, 1, 3, structureBoundingBoxIn);
                this.setBlockState(worldIn, Blocks.WOODEN_PRESSURE_PLATE.getDefaultState(), this.tablePosition, 2, 3, structureBoundingBoxIn);
            }

            this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), 1, 1, 0, structureBoundingBoxIn);
            this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), 1, 2, 0, structureBoundingBoxIn);
            this.placeDoor(worldIn, structureBoundingBoxIn, randomIn, 1, 1, 0, EnumFacing.NORTH);

            if (this.getBlockStateFromPos(worldIn, 1, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 1, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR) {
                this.setBlockState(worldIn, iblockstate2, 1, 0, -1, structureBoundingBoxIn);

            }

            for (int i = 0; i < 5; ++i) {
                for (int j = 0; j < 4; ++j) {
                    this.clearCurrentPositionBlocksUpwards(worldIn, j, 6, i, structureBoundingBoxIn);
                    this.replaceAirAndLiquidDownwards(worldIn, iblockstate, j, -1, i, structureBoundingBoxIn);
                }
            }

            this.spawnVillagers(worldIn, structureBoundingBoxIn, 1, 1, 2, 1);
            return true;
        }
 
Example #26
Source File: StructureTofuVillagePieces.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 9 - 1, 0);
    }


    IBlockState iblockstate = this.getBiomeSpecificBlockState(BlockLoader.tofuTerrain.getDefaultState());
    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
    IBlockState air = Blocks.AIR.getDefaultState();
    IBlockState iblockstate3 = BlockLoader.ISHITOFU.getDefaultState();

    this.fillWithBlocks(worldIn,structureBoundingBoxIn,0,0,0,6,4,6,iblockstate1,iblockstate1,false);
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,1,1,1,5,3,5,air,air,false);

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 2, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 2, 3, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 3, 5, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.CRAFTING_TABLE.getDefaultState(), 1, 1, 4, structureBoundingBoxIn);

    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 1, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFU_LEAVE.getDefaultState(), 1, 6, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 5, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFU_LEAVE.getDefaultState(), 5, 6, 1, structureBoundingBoxIn);

    IBlockState iblockstate5 = BlockLoader.TOFUISHI_BRICK_LADDER.getDefaultState().withProperty(BlockLadder.FACING, EnumFacing.SOUTH);
    this.setBlockState(worldIn, iblockstate5, 5, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 3, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 4, 5, structureBoundingBoxIn);
    //2F
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,0,5,0,6,9,6,iblockstate1,iblockstate1,false);
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,1,5,1,5,8,5,air,air,false);

    this.fillWithBlocks(worldIn,structureBoundingBoxIn,0,0,0,0,9,0,iblockstate3,iblockstate3,false);
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,6,0,0,6,9,0,iblockstate3,iblockstate3,false);
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,0,0,6,0,9,6,iblockstate3,iblockstate3,false);
    this.fillWithBlocks(worldIn,structureBoundingBoxIn,6,0,6,6,9,6,iblockstate3,iblockstate3,false);

    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 1, 5, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFU_LEAVE.getDefaultState(), 1, 6, 5, structureBoundingBoxIn);

    BlockPos blockpos = new BlockPos(this.getXWithOffset(2,5), this.getYWithOffset(5), this.getZWithOffset(2,5));

    this.generateChest(worldIn,structureBoundingBoxIn,randomIn,blockpos, TofuLootTables.tofuhouse,BlockLoader.TOFUCHEST.getDefaultState().withProperty(BlockTofuChest.FACING, EnumFacing.EAST));

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 0, structureBoundingBoxIn);



    if (this.getBlockStateFromPos(worldIn, 3, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 3, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR)
    {
        this.setBlockState(worldIn, iblockstate2, 3, 0, -1, structureBoundingBoxIn);

    }


    this.placeTorch(worldIn, EnumFacing.NORTH, 3, 3, 1, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 3, 5, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 7, 5, structureBoundingBoxIn);

    this.placeDoor(worldIn, structureBoundingBoxIn, randomIn, 3, 1, 0, EnumFacing.NORTH);

    for (int j = 0; j < 7; ++j)
    {
        for (int i = 0; i < 7; ++i)
        {
            this.clearCurrentPositionBlocksUpwards(worldIn, i, 10, j, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate, i, -1, j, structureBoundingBoxIn);
        }
    }

    this.spawnVillagers(worldIn, structureBoundingBoxIn, 4, 6, 4, 2,2);

    this.spawnVillagers(worldIn, structureBoundingBoxIn, 4, 1, 4, 1);
    return true;
}
 
Example #27
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
{
	return state.withProperty(BlockStairs.SHAPE, func_185706_d(state, worldIn, pos));
}
 
Example #28
Source File: BlockStairsTFC.java    From TFC2 with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected BlockStateContainer createBlockState()
{
	return new BlockStateContainer(this, new IProperty[] { BlockStairs.FACING, BlockStairs.HALF, BlockStairs.SHAPE });
}
 
Example #29
Source File: TofuVillagerHouse.java    From TofuCraftReload with MIT License 4 votes vote down vote up
/**
 * second Part of Structure generating, this for example places Spiderwebs, Mob Spawners, it closes
 * Mineshafts at the end, it adds Fences...
 */
public boolean addComponentParts(World worldIn, Random randomIn, StructureBoundingBox structureBoundingBoxIn) {
    if (this.averageGroundLvl < 0) {
        this.averageGroundLvl = this.getAverageGroundLevel(worldIn, structureBoundingBoxIn);

        if (this.averageGroundLvl < 0) {
            return true;
        }

        this.boundingBox.offset(0, this.averageGroundLvl - this.boundingBox.maxY + 9 - 1, 0);
    }

    IBlockState iblockstate1 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK.getDefaultState());
    IBlockState iblockstate2 = this.getBiomeSpecificBlockState(BlockLoader.TOFUISHI_BRICK_STAIRS.getDefaultState().withProperty(BlockStairs.FACING, EnumFacing.NORTH));
    IBlockState air = Blocks.AIR.getDefaultState();
    IBlockState iblockstate3 = BlockLoader.ISHITOFU.getDefaultState();

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 6, 4, 6, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 1, 1, 5, 3, 5, air, air, false);

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 2, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 2, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 2, 3, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.BOOKSHELF.getDefaultState(), 1, 3, 5, structureBoundingBoxIn);

    this.setBlockState(worldIn, Blocks.CRAFTING_TABLE.getDefaultState(), 1, 1, 4, structureBoundingBoxIn);

    this.setBlockState(worldIn, BlockLoader.SALTFURNACE.getDefaultState(), 1, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.CAULDRON.getDefaultState(), 1, 6, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 5, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFUISHI_BRICK.getDefaultState(), 5, 6, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 4, 5, 1, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFUISHI_BRICK.getDefaultState(), 5, 6, 1, structureBoundingBoxIn);

    IBlockState iblockstate5 = BlockLoader.TOFUISHI_BRICK_LADDER.getDefaultState().withProperty(BlockLadder.FACING, EnumFacing.SOUTH);
    this.setBlockState(worldIn, iblockstate5, 5, 1, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 2, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 3, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, iblockstate5, 5, 4, 5, structureBoundingBoxIn);
    //2F
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 5, 0, 6, 9, 6, iblockstate1, iblockstate1, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 1, 5, 1, 5, 8, 5, air, air, false);

    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 0, 0, 9, 0, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 0, 0, 6, 9, 0, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 0, 0, 6, 0, 9, 6, iblockstate3, iblockstate3, false);
    this.fillWithBlocks(worldIn, structureBoundingBoxIn, 6, 0, 6, 6, 9, 6, iblockstate3, iblockstate3, false);

    this.setBlockState(worldIn, BlockLoader.ISHITOFU.getDefaultState(), 1, 5, 5, structureBoundingBoxIn);
    this.setBlockState(worldIn, BlockLoader.TOFU_LEAVE.getDefaultState(), 1, 6, 5, structureBoundingBoxIn);

    BlockPos blockpos = new BlockPos(this.getXWithOffset(2, 5), this.getYWithOffset(5), this.getZWithOffset(2, 5));

    this.generateChest(worldIn, structureBoundingBoxIn, randomIn, blockpos, TofuLootTables.tofuhouse, BlockLoader.TOFUCHEST.getDefaultState().withProperty(BlockTofuChest.FACING, EnumFacing.EAST));

    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 0, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 6, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 6, 6, 3, structureBoundingBoxIn);
    this.setBlockState(worldIn, Blocks.GLASS_PANE.getDefaultState(), 3, 6, 0, structureBoundingBoxIn);


    if (this.getBlockStateFromPos(worldIn, 3, 0, -1, structureBoundingBoxIn).getMaterial() == Material.AIR && this.getBlockStateFromPos(worldIn, 3, -1, -1, structureBoundingBoxIn).getMaterial() != Material.AIR) {
        this.setBlockState(worldIn, iblockstate2, 3, 0, -1, structureBoundingBoxIn);

    }


    this.placeTorch(worldIn, EnumFacing.NORTH, 3, 3, 1, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 3, 5, structureBoundingBoxIn);
    this.placeTorch(worldIn, EnumFacing.SOUTH, 3, 7, 5, structureBoundingBoxIn);

    this.createVillageDoor(worldIn, structureBoundingBoxIn, randomIn, 3, 1, 0, EnumFacing.NORTH);


    this.spawnVillagers(worldIn, structureBoundingBoxIn, 4, 1, 4, 2);

    for (int l = 0; l < 6; ++l) {
        for (int k = 0; k < 6; ++k) {
            this.clearCurrentPositionBlocksUpwards(worldIn, k, 9, l, structureBoundingBoxIn);
            this.replaceAirAndLiquidDownwards(worldIn, iblockstate1, k, -1, l, structureBoundingBoxIn);
        }
    }

    return true;
}