net.minecraft.block.BlockStairs.EnumHalf Java Examples

The following examples show how to use net.minecraft.block.BlockStairs.EnumHalf. 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: 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 #2
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 #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
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 #5
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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
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;
}