Files
2019-02-24 22:29:41 +08:00

241 lines
12 KiB
Diff

--- ../src-base/minecraft/net/minecraft/block/BlockStairs.java
+++ ../src-work/minecraft/net/minecraft/block/BlockStairs.java
@@ -35,8 +35,8 @@
public class BlockStairs extends Block
{
public static final PropertyDirection FACING = BlockHorizontal.FACING;
- public static final PropertyEnum<BlockStairs.EnumHalf> HALF = PropertyEnum.<BlockStairs.EnumHalf>create("half", BlockStairs.EnumHalf.class);
- public static final PropertyEnum<BlockStairs.EnumShape> SHAPE = PropertyEnum.<BlockStairs.EnumShape>create("shape", BlockStairs.EnumShape.class);
+ public static final PropertyEnum<EnumHalf> HALF = PropertyEnum.<EnumHalf>create("half", EnumHalf.class);
+ public static final PropertyEnum<EnumShape> SHAPE = PropertyEnum.<EnumShape>create("shape", EnumShape.class);
protected static final AxisAlignedBB AABB_SLAB_TOP = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
protected static final AxisAlignedBB AABB_QTR_TOP_WEST = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 0.5D, 1.0D, 1.0D);
protected static final AxisAlignedBB AABB_QTR_TOP_EAST = new AxisAlignedBB(0.5D, 0.5D, 0.0D, 1.0D, 1.0D, 1.0D);
@@ -61,7 +61,7 @@
protected BlockStairs(IBlockState modelState)
{
super(modelState.getBlock().blockMaterial);
- this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HALF, BlockStairs.EnumHalf.BOTTOM).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT));
+ this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HALF, EnumHalf.BOTTOM).withProperty(SHAPE, EnumShape.STRAIGHT));
this.modelBlock = modelState.getBlock();
this.modelState = modelState;
this.setHardness(this.modelBlock.blockHardness);
@@ -87,16 +87,16 @@
private static List<AxisAlignedBB> getCollisionBoxList(IBlockState bstate)
{
List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
- boolean flag = bstate.getValue(HALF) == BlockStairs.EnumHalf.TOP;
+ boolean flag = bstate.getValue(HALF) == EnumHalf.TOP;
list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM);
- BlockStairs.EnumShape blockstairs$enumshape = (BlockStairs.EnumShape)bstate.getValue(SHAPE);
+ EnumShape blockstairs$enumshape = (EnumShape)bstate.getValue(SHAPE);
- if (blockstairs$enumshape == BlockStairs.EnumShape.STRAIGHT || blockstairs$enumshape == BlockStairs.EnumShape.INNER_LEFT || blockstairs$enumshape == BlockStairs.EnumShape.INNER_RIGHT)
+ if (blockstairs$enumshape == EnumShape.STRAIGHT || blockstairs$enumshape == EnumShape.INNER_LEFT || blockstairs$enumshape == EnumShape.INNER_RIGHT)
{
list.add(getCollQuarterBlock(bstate));
}
- if (blockstairs$enumshape != BlockStairs.EnumShape.STRAIGHT)
+ if (blockstairs$enumshape != EnumShape.STRAIGHT)
{
list.add(getCollEighthBlock(bstate));
}
@@ -106,7 +106,7 @@
private static AxisAlignedBB getCollQuarterBlock(IBlockState bstate)
{
- boolean flag = bstate.getValue(HALF) == BlockStairs.EnumHalf.TOP;
+ boolean flag = bstate.getValue(HALF) == EnumHalf.TOP;
switch ((EnumFacing)bstate.getValue(FACING))
{
@@ -127,7 +127,7 @@
EnumFacing enumfacing = (EnumFacing)bstate.getValue(FACING);
EnumFacing enumfacing1;
- switch ((BlockStairs.EnumShape)bstate.getValue(SHAPE))
+ switch ((EnumShape)bstate.getValue(SHAPE))
{
case OUTER_LEFT:
default:
@@ -143,7 +143,7 @@
enumfacing1 = enumfacing.rotateYCCW();
}
- boolean flag = bstate.getValue(HALF) == BlockStairs.EnumHalf.TOP;
+ boolean flag = bstate.getValue(HALF) == EnumHalf.TOP;
switch (enumfacing1)
{
@@ -165,13 +165,13 @@
if (face.getAxis() == EnumFacing.Axis.Y)
{
- return face == EnumFacing.UP == (state.getValue(HALF) == BlockStairs.EnumHalf.TOP) ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
+ return face == EnumFacing.UP == (state.getValue(HALF) == EnumHalf.TOP) ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
}
else
{
- BlockStairs.EnumShape blockstairs$enumshape = (BlockStairs.EnumShape)state.getValue(SHAPE);
+ EnumShape blockstairs$enumshape = (EnumShape)state.getValue(SHAPE);
- if (blockstairs$enumshape != BlockStairs.EnumShape.OUTER_LEFT && blockstairs$enumshape != BlockStairs.EnumShape.OUTER_RIGHT)
+ if (blockstairs$enumshape != EnumShape.OUTER_LEFT && blockstairs$enumshape != EnumShape.OUTER_RIGHT)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
@@ -301,7 +301,7 @@
public boolean isTopSolid(IBlockState state)
{
- return state.getValue(HALF) == BlockStairs.EnumHalf.TOP;
+ return state.getValue(HALF) == EnumHalf.TOP;
}
public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
@@ -312,8 +312,8 @@
public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
IBlockState iblockstate = super.getStateForPlacement(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer);
- iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing()).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT);
- return facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double)hitY <= 0.5D) ? iblockstate.withProperty(HALF, BlockStairs.EnumHalf.BOTTOM) : iblockstate.withProperty(HALF, BlockStairs.EnumHalf.TOP);
+ iblockstate = iblockstate.withProperty(FACING, placer.getHorizontalFacing()).withProperty(SHAPE, EnumShape.STRAIGHT);
+ return facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double)hitY <= 0.5D) ? iblockstate.withProperty(HALF, EnumHalf.BOTTOM) : iblockstate.withProperty(HALF, EnumHalf.TOP);
}
@Nullable
@@ -348,7 +348,7 @@
public IBlockState getStateFromMeta(int meta)
{
- IBlockState iblockstate = this.getDefaultState().withProperty(HALF, (meta & 4) > 0 ? BlockStairs.EnumHalf.TOP : BlockStairs.EnumHalf.BOTTOM);
+ IBlockState iblockstate = this.getDefaultState().withProperty(HALF, (meta & 4) > 0 ? EnumHalf.TOP : EnumHalf.BOTTOM);
iblockstate = iblockstate.withProperty(FACING, EnumFacing.getFront(5 - (meta & 3)));
return iblockstate;
}
@@ -357,7 +357,7 @@
{
int i = 0;
- if (state.getValue(HALF) == BlockStairs.EnumHalf.TOP)
+ if (state.getValue(HALF) == EnumHalf.TOP)
{
i |= 4;
}
@@ -371,7 +371,7 @@
return state.withProperty(SHAPE, getStairsShape(state, worldIn, pos));
}
- private static BlockStairs.EnumShape getStairsShape(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
+ private static EnumShape getStairsShape(IBlockState p_185706_0_, IBlockAccess p_185706_1_, BlockPos p_185706_2_)
{
EnumFacing enumfacing = (EnumFacing)p_185706_0_.getValue(FACING);
IBlockState iblockstate = p_185706_1_.getBlockState(p_185706_2_.offset(enumfacing));
@@ -384,10 +384,10 @@
{
if (enumfacing1 == enumfacing.rotateYCCW())
{
- return BlockStairs.EnumShape.OUTER_LEFT;
+ return EnumShape.OUTER_LEFT;
}
- return BlockStairs.EnumShape.OUTER_RIGHT;
+ return EnumShape.OUTER_RIGHT;
}
}
@@ -401,14 +401,14 @@
{
if (enumfacing2 == enumfacing.rotateYCCW())
{
- return BlockStairs.EnumShape.INNER_LEFT;
+ return EnumShape.INNER_LEFT;
}
- return BlockStairs.EnumShape.INNER_RIGHT;
+ return EnumShape.INNER_RIGHT;
}
}
- return BlockStairs.EnumShape.STRAIGHT;
+ return EnumShape.STRAIGHT;
}
private static boolean isDifferentStairs(IBlockState p_185704_0_, IBlockAccess p_185704_1_, BlockPos p_185704_2_, EnumFacing p_185704_3_)
@@ -431,7 +431,7 @@
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
- BlockStairs.EnumShape blockstairs$enumshape = (BlockStairs.EnumShape)state.getValue(SHAPE);
+ EnumShape blockstairs$enumshape = (EnumShape)state.getValue(SHAPE);
switch (mirrorIn)
{
@@ -442,13 +442,13 @@
switch (blockstairs$enumshape)
{
case OUTER_LEFT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_RIGHT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.OUTER_RIGHT);
case OUTER_RIGHT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_LEFT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.OUTER_LEFT);
case INNER_RIGHT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_LEFT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.INNER_LEFT);
case INNER_LEFT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_RIGHT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.INNER_RIGHT);
default:
return state.withRotation(Rotation.CLOCKWISE_180);
}
@@ -462,13 +462,13 @@
switch (blockstairs$enumshape)
{
case OUTER_LEFT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_RIGHT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.OUTER_RIGHT);
case OUTER_RIGHT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.OUTER_LEFT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.OUTER_LEFT);
case INNER_RIGHT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_RIGHT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.INNER_RIGHT);
case INNER_LEFT:
- return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, BlockStairs.EnumShape.INNER_LEFT);
+ return state.withRotation(Rotation.CLOCKWISE_180).withProperty(SHAPE, EnumShape.INNER_LEFT);
case STRAIGHT:
return state.withRotation(Rotation.CLOCKWISE_180);
}
@@ -483,6 +483,29 @@
return new BlockStateContainer(this, new IProperty[] {FACING, HALF, SHAPE});
}
+ @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(HALF);
+ EnumFacing side = state.getValue(FACING);
+ EnumShape shape = state.getValue(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;
+ }
+
public static enum EnumHalf implements IStringSerializable
{
TOP("top"),