2016-09-06 20:53:52 +00:00
|
|
|
package WayofTime.bloodmagic.block.base;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import javax.annotation.Nullable;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockHorizontal;
|
|
|
|
import net.minecraft.block.BlockStairs;
|
|
|
|
import net.minecraft.block.BlockStairs.EnumHalf;
|
|
|
|
import net.minecraft.block.BlockStairs.EnumShape;
|
|
|
|
import net.minecraft.block.material.Material;
|
|
|
|
import net.minecraft.block.properties.PropertyDirection;
|
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
|
|
import net.minecraft.entity.EntityLivingBase;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
2017-01-02 05:43:34 +00:00
|
|
|
import net.minecraft.util.*;
|
2016-09-06 20:53:52 +00:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.RayTraceResult;
|
|
|
|
import net.minecraft.util.math.Vec3d;
|
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2016-12-13 03:56:36 +00:00
|
|
|
import net.minecraftforge.common.ForgeModContainer;
|
2016-10-15 16:21:30 +00:00
|
|
|
import org.apache.commons.lang3.ArrayUtils;
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-10-16 02:02:16 +00:00
|
|
|
import WayofTime.bloodmagic.BloodMagic;
|
|
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
|
|
public class BlockEnumStairs<E extends Enum<E> & IStringSerializable> extends BlockEnum<E>
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
public static final PropertyDirection FACING = BlockHorizontal.FACING;
|
|
|
|
|
|
|
|
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);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_TOP_NORTH = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 1.0D, 1.0D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_TOP_SOUTH = new AxisAlignedBB(0.0D, 0.5D, 0.5D, 1.0D, 1.0D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_TOP_NW = new AxisAlignedBB(0.0D, 0.5D, 0.0D, 0.5D, 1.0D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_TOP_NE = new AxisAlignedBB(0.5D, 0.5D, 0.0D, 1.0D, 1.0D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_TOP_SW = new AxisAlignedBB(0.0D, 0.5D, 0.5D, 0.5D, 1.0D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_TOP_SE = new AxisAlignedBB(0.5D, 0.5D, 0.5D, 1.0D, 1.0D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_SLAB_BOTTOM = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_BOT_WEST = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.5D, 0.5D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_BOT_EAST = new AxisAlignedBB(0.5D, 0.0D, 0.0D, 1.0D, 0.5D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_BOT_NORTH = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.5D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_QTR_BOT_SOUTH = new AxisAlignedBB(0.0D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_BOT_NW = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 0.5D, 0.5D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_BOT_NE = new AxisAlignedBB(0.5D, 0.0D, 0.0D, 1.0D, 0.5D, 0.5D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_BOT_SW = new AxisAlignedBB(0.0D, 0.0D, 0.5D, 0.5D, 0.5D, 1.0D);
|
|
|
|
protected static final AxisAlignedBB AABB_OCT_BOT_SE = new AxisAlignedBB(0.5D, 0.0D, 0.5D, 1.0D, 0.5D, 1.0D);
|
|
|
|
|
2016-10-16 02:02:16 +00:00
|
|
|
public BlockEnumStairs(Material material, Class<E> enumClass, String propName)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-10-16 02:02:16 +00:00
|
|
|
super(material, enumClass, propName);
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
2016-10-16 02:02:16 +00:00
|
|
|
public BlockEnumStairs(Material material, Class<E> enumClass)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-10-16 02:02:16 +00:00
|
|
|
this(material, enumClass, "type");
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 16:21:30 +00:00
|
|
|
@Override
|
2016-10-16 02:02:16 +00:00
|
|
|
protected BlockStateContainer createStateContainer()
|
|
|
|
{
|
2016-10-15 16:21:30 +00:00
|
|
|
return new BlockStateContainer.Builder(this).add(getProperty(), FACING, BlockStairs.HALF, BlockStairs.SHAPE).build();
|
|
|
|
}
|
|
|
|
|
2016-09-06 20:53:52 +00:00
|
|
|
@Override
|
|
|
|
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn)
|
|
|
|
{
|
|
|
|
state = this.getActualState(state, worldIn, pos);
|
|
|
|
|
|
|
|
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(state))
|
|
|
|
{
|
|
|
|
addCollisionBoxToList(pos, entityBox, collidingBoxes, axisalignedbb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
private static List<AxisAlignedBB> getCollisionBoxList(IBlockState state)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
List<AxisAlignedBB> list = Lists.newArrayList();
|
|
|
|
boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;
|
2016-09-06 20:53:52 +00:00
|
|
|
list.add(flag ? AABB_SLAB_TOP : AABB_SLAB_BOTTOM);
|
2016-09-07 00:13:43 +00:00
|
|
|
BlockStairs.EnumShape stairShape = state.getValue(BlockStairs.SHAPE);
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (stairShape == BlockStairs.EnumShape.STRAIGHT || stairShape == BlockStairs.EnumShape.INNER_LEFT || stairShape == BlockStairs.EnumShape.INNER_RIGHT)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
list.add(getCollQuarterBlock(state));
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (stairShape != BlockStairs.EnumShape.STRAIGHT)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
list.add(getCollEighthBlock(state));
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
private static AxisAlignedBB getCollQuarterBlock(IBlockState state)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
boolean flag = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
switch (state.getValue(FACING))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
private static AxisAlignedBB getCollEighthBlock(IBlockState state)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
EnumFacing facing = state.getValue(FACING);
|
|
|
|
EnumFacing newFacing;
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
switch (state.getValue(BlockStairs.SHAPE))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
case OUTER_LEFT:
|
|
|
|
default:
|
2016-09-07 00:13:43 +00:00
|
|
|
newFacing = facing;
|
2016-09-06 20:53:52 +00:00
|
|
|
break;
|
|
|
|
case OUTER_RIGHT:
|
2016-09-07 00:13:43 +00:00
|
|
|
newFacing = facing.rotateY();
|
2016-09-06 20:53:52 +00:00
|
|
|
break;
|
|
|
|
case INNER_RIGHT:
|
2016-09-07 00:13:43 +00:00
|
|
|
newFacing = facing.getOpposite();
|
2016-09-06 20:53:52 +00:00
|
|
|
break;
|
|
|
|
case INNER_LEFT:
|
2016-09-07 00:13:43 +00:00
|
|
|
newFacing = facing.rotateYCCW();
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
boolean isTop = state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP;
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
switch (newFacing)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
case NORTH:
|
|
|
|
default:
|
2016-09-07 00:13:43 +00:00
|
|
|
return isTop ? AABB_OCT_BOT_NW : AABB_OCT_TOP_NW;
|
2016-09-06 20:53:52 +00:00
|
|
|
case SOUTH:
|
2016-09-07 00:13:43 +00:00
|
|
|
return isTop ? AABB_OCT_BOT_SE : AABB_OCT_TOP_SE;
|
2016-09-06 20:53:52 +00:00
|
|
|
case WEST:
|
2016-09-07 00:13:43 +00:00
|
|
|
return isTop ? AABB_OCT_BOT_SW : AABB_OCT_TOP_SW;
|
2016-09-06 20:53:52 +00:00
|
|
|
case EAST:
|
2016-09-07 00:13:43 +00:00
|
|
|
return isTop ? AABB_OCT_BOT_NE : AABB_OCT_TOP_NE;
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isOpaqueCube(IBlockState state)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isFullCube(IBlockState state)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-01-02 05:43:34 +00:00
|
|
|
public IBlockState getStateForPlacement(World world, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer, EnumHand hand)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2017-01-02 05:43:34 +00:00
|
|
|
IBlockState state = super.getStateForPlacement(world, pos, facing, hitX, hitY, hitZ, meta, placer, hand);
|
2016-09-07 00:13:43 +00:00
|
|
|
state = state.withProperty(FACING, placer.getHorizontalFacing()).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.STRAIGHT);
|
|
|
|
return facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double) hitY <= 0.5D) ? state.withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.BOTTOM) : state.withProperty(BlockStairs.HALF, BlockStairs.EnumHalf.TOP);
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public RayTraceResult collisionRayTrace(IBlockState blockState, World worldIn, BlockPos pos, Vec3d start, Vec3d end)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
List<RayTraceResult> list = Lists.newArrayList();
|
2016-09-06 20:53:52 +00:00
|
|
|
|
|
|
|
for (AxisAlignedBB axisalignedbb : getCollisionBoxList(this.getActualState(blockState, worldIn, pos)))
|
|
|
|
{
|
|
|
|
list.add(this.rayTrace(pos, start, end, axisalignedbb));
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
RayTraceResult rayTrace = null;
|
2016-09-06 20:53:52 +00:00
|
|
|
double d1 = 0.0D;
|
|
|
|
|
|
|
|
for (RayTraceResult raytraceresult : list)
|
|
|
|
{
|
|
|
|
if (raytraceresult != null)
|
|
|
|
{
|
|
|
|
double d0 = raytraceresult.hitVec.squareDistanceTo(end);
|
|
|
|
|
|
|
|
if (d0 > d1)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
rayTrace = raytraceresult;
|
2016-09-06 20:53:52 +00:00
|
|
|
d1 = d0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
return rayTrace;
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Meta looks like: {1|11|1} = {HALF|FACING|TYPE}
|
|
|
|
@Override
|
|
|
|
public IBlockState getStateFromMeta(int meta)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
IBlockState state = getBlockState().getBaseState().withProperty(BlockStairs.HALF, (meta & 8) > 0 ? BlockStairs.EnumHalf.TOP : BlockStairs.EnumHalf.BOTTOM);
|
2016-10-15 16:21:30 +00:00
|
|
|
state = state.withProperty(FACING, EnumFacing.getFront(5 - (meta & 6) / 2)).withProperty(this.getProperty(), getTypes()[meta % 2]);
|
2016-09-07 00:13:43 +00:00
|
|
|
return state;
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Meta looks like: {1|11|1} = {HALF|FACING|TYPE}
|
|
|
|
@Override
|
|
|
|
public int getMetaFromState(IBlockState state)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
if (state.getValue(BlockStairs.HALF) == BlockStairs.EnumHalf.TOP)
|
|
|
|
{
|
|
|
|
i |= 4;
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
i = i | 5 - state.getValue(FACING).getIndex();
|
2016-10-15 16:21:30 +00:00
|
|
|
return i * 2 + ArrayUtils.indexOf(getTypes(), state.getValue(getProperty()));
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos)
|
|
|
|
{
|
|
|
|
return state.withProperty(BlockStairs.SHAPE, getStairsShape(state, worldIn, pos));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static BlockStairs.EnumShape getStairsShape(IBlockState state, IBlockAccess world, BlockPos pos)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
EnumFacing facing = state.getValue(FACING);
|
|
|
|
IBlockState offsetState = world.getBlockState(pos.offset(facing));
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (isBlockStairs(offsetState) && state.getValue(BlockStairs.HALF) == offsetState.getValue(BlockStairs.HALF))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
EnumFacing offsetFacing = offsetState.getValue(FACING);
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (offsetFacing.getAxis() != state.getValue(FACING).getAxis() && isDifferentStairs(state, world, pos, offsetFacing.getOpposite()))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
if (offsetFacing == facing.rotateYCCW())
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
return BlockStairs.EnumShape.OUTER_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BlockStairs.EnumShape.OUTER_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
IBlockState oppositeOffsetState = world.getBlockState(pos.offset(facing.getOpposite()));
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (isBlockStairs(oppositeOffsetState) && state.getValue(BlockStairs.HALF) == oppositeOffsetState.getValue(BlockStairs.HALF))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
EnumFacing oppositeOffsetFacing = oppositeOffsetState.getValue(FACING);
|
2016-09-06 20:53:52 +00:00
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (oppositeOffsetFacing.getAxis() != (state.getValue(FACING)).getAxis() && isDifferentStairs(state, world, pos, oppositeOffsetFacing))
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
if (oppositeOffsetFacing == facing.rotateYCCW())
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
return BlockStairs.EnumShape.INNER_LEFT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return BlockStairs.EnumShape.INNER_RIGHT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return BlockStairs.EnumShape.STRAIGHT;
|
|
|
|
}
|
|
|
|
|
|
|
|
private static boolean isDifferentStairs(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing facing)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
IBlockState offsetState = world.getBlockState(pos.offset(facing));
|
|
|
|
return !isBlockStairs(offsetState) || offsetState.getValue(FACING) != state.getValue(FACING) || offsetState.getValue(BlockStairs.HALF) != state.getValue(BlockStairs.HALF);
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static boolean isBlockStairs(IBlockState state)
|
|
|
|
{
|
2016-10-16 02:02:16 +00:00
|
|
|
return state.getBlock() instanceof BlockStairs || state.getBlock() instanceof BlockEnumStairs;
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public IBlockState withRotation(IBlockState state, Rotation rot)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
return state.withProperty(FACING, rot.rotate(state.getValue(FACING)));
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("incomplete-switch")
|
|
|
|
@Override
|
|
|
|
public IBlockState withMirror(IBlockState state, Mirror mirrorIn)
|
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
EnumFacing facing = state.getValue(FACING);
|
|
|
|
BlockStairs.EnumShape stairShape = state.getValue(BlockStairs.SHAPE);
|
2016-09-06 20:53:52 +00:00
|
|
|
|
|
|
|
switch (mirrorIn)
|
|
|
|
{
|
|
|
|
case LEFT_RIGHT:
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (facing.getAxis() == EnumFacing.Axis.Z)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
switch (stairShape)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
case OUTER_LEFT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT);
|
|
|
|
case OUTER_RIGHT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT);
|
|
|
|
case INNER_RIGHT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT);
|
|
|
|
case INNER_LEFT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT);
|
|
|
|
default:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
case FRONT_BACK:
|
|
|
|
|
2016-09-07 00:13:43 +00:00
|
|
|
if (facing.getAxis() == EnumFacing.Axis.X)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
2016-09-07 00:13:43 +00:00
|
|
|
switch (stairShape)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
case OUTER_LEFT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_RIGHT);
|
|
|
|
case OUTER_RIGHT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.OUTER_LEFT);
|
|
|
|
case INNER_RIGHT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_RIGHT);
|
|
|
|
case INNER_LEFT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180).withProperty(BlockStairs.SHAPE, BlockStairs.EnumShape.INNER_LEFT);
|
|
|
|
case STRAIGHT:
|
|
|
|
return state.withRotation(Rotation.CLOCKWISE_180);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return super.withMirror(state, mirrorIn);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-01-02 05:43:34 +00:00
|
|
|
protected ItemStack getSilkTouchDrop(IBlockState state)
|
2016-09-06 20:53:52 +00:00
|
|
|
{
|
|
|
|
return new ItemStack(this, 1, damageDropped(state));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int damageDropped(IBlockState state)
|
|
|
|
{
|
2016-10-15 16:21:30 +00:00
|
|
|
return super.getMetaFromState(state);
|
2016-09-06 20:53:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player)
|
|
|
|
{
|
|
|
|
return new ItemStack(this, 1, damageDropped(state));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean doesSideBlockRendering(IBlockState state, IBlockAccess world, BlockPos pos, EnumFacing face)
|
|
|
|
{
|
2016-12-13 03:56:36 +00:00
|
|
|
if (ForgeModContainer.disableStairSlabCulling)
|
2016-09-06 20:53:52 +00:00
|
|
|
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(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;
|
|
|
|
}
|
|
|
|
}
|