public class SlateTrigonousBlock extends Block{
public static final DirectionProperty FACING = HorizontalBlock.HORIZONTAL_FACING;
private static final VoxelShape SHAPE_N = Stream.of(
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 1, 16, 2, 16),
Block.makeCuboidShape(0, 2, 2, 16, 3, 16),
Block.makeCuboidShape(0, 3, 3, 16, 4, 16),
Block.makeCuboidShape(0, 4, 4, 16, 5, 16),
Block.makeCuboidShape(0, 5, 5, 16, 6, 16),
Block.makeCuboidShape(0, 6, 6, 16, 7, 16),
Block.makeCuboidShape(0, 7, 7, 16, 8, 16),
Block.makeCuboidShape(0, 8, 8, 16, 9, 16),
Block.makeCuboidShape(0, 0, 0, 1, 1, 1),
Block.makeCuboidShape(0, 9, 9, 16, 10, 16),
Block.makeCuboidShape(0, 10, 10, 16, 11, 16),
Block.makeCuboidShape(0, 11, 11, 16, 12, 16),
Block.makeCuboidShape(0, 12, 12, 16, 13, 16),
Block.makeCuboidShape(0, 13, 13, 16, 14, 16),
Block.makeCuboidShape(0, 14, 14, 16, 15, 16),
Block.makeCuboidShape(0, 15, 15, 16, 16, 16)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_W = Stream.of(
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(1, 1, 0, 16, 2, 16),
Block.makeCuboidShape(2, 2, 0, 16, 3, 16),
Block.makeCuboidShape(3, 3, 0, 16, 4, 16),
Block.makeCuboidShape(4, 4, 0, 16, 5, 16),
Block.makeCuboidShape(5, 5, 0, 16, 6, 16),
Block.makeCuboidShape(6, 6, 0, 16, 7, 16),
Block.makeCuboidShape(7, 7, 0, 16, 8, 16),
Block.makeCuboidShape(8, 8, 0, 16, 9, 16),
Block.makeCuboidShape(0, 0, 15, 1, 1, 16),
Block.makeCuboidShape(9, 9, 0, 16, 10, 16),
Block.makeCuboidShape(10, 10, 0, 16, 11, 16),
Block.makeCuboidShape(11, 11, 0, 16, 12, 16),
Block.makeCuboidShape(12, 12, 0, 16, 13, 16),
Block.makeCuboidShape(13, 13, 0, 16, 14, 16),
Block.makeCuboidShape(14, 14, 0, 16, 15, 16),
Block.makeCuboidShape(15, 15, 0, 16, 16, 16)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_S = Stream.of(
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 0, 16, 2, 15),
Block.makeCuboidShape(0, 2, 0, 16, 3, 14),
Block.makeCuboidShape(0, 3, 0, 16, 4, 13),
Block.makeCuboidShape(0, 4, 0, 16, 5, 12),
Block.makeCuboidShape(0, 5, 0, 16, 6, 11),
Block.makeCuboidShape(0, 6, 0, 16, 7, 10),
Block.makeCuboidShape(0, 7, 0, 16, 8, 9),
Block.makeCuboidShape(0, 8, 0, 16, 9, 8),
Block.makeCuboidShape(15, 0, 15, 16, 1, 16),
Block.makeCuboidShape(0, 9, 0, 16, 10, 7),
Block.makeCuboidShape(0, 10, 0, 16, 11, 6),
Block.makeCuboidShape(0, 11, 0, 16, 12, 5),
Block.makeCuboidShape(0, 12, 0, 16, 13, 4),
Block.makeCuboidShape(0, 13, 0, 16, 14, 3),
Block.makeCuboidShape(0, 14, 0, 16, 15, 2),
Block.makeCuboidShape(0, 15, 0, 16, 16, 1)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public static final VoxelShape SHAPE_E = Stream.of(
Block.makeCuboidShape(0, 0, 0, 16, 1, 16),
Block.makeCuboidShape(0, 1, 0, 15, 2, 16),
Block.makeCuboidShape(0, 2, 0, 14, 3, 16),
Block.makeCuboidShape(0, 3, 0, 13, 4, 16),
Block.makeCuboidShape(0, 4, 0, 12, 5, 16),
Block.makeCuboidShape(0, 5, 0, 11, 6, 16),
Block.makeCuboidShape(0, 6, 0, 10, 7, 16),
Block.makeCuboidShape(0, 7, 0, 9, 8, 16),
Block.makeCuboidShape(0, 8, 0, 8, 9, 16),
Block.makeCuboidShape(15, 0, 0, 16, 1, 1),
Block.makeCuboidShape(0, 9, 0, 7, 10, 16),
Block.makeCuboidShape(0, 10, 0, 6, 11, 16),
Block.makeCuboidShape(0, 11, 0, 5, 12, 16),
Block.makeCuboidShape(0, 12, 0, 4, 13, 16),
Block.makeCuboidShape(0, 13, 0, 3, 14, 16),
Block.makeCuboidShape(0, 14, 0, 2, 15, 16),
Block.makeCuboidShape(0, 15, 0, 1, 16, 16)
).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
public SlateTrigonousBlock()
{
super(Block.Properties.create(Material.ROCK)
.hardnessAndResistance(2.5f, 10.0f)
.harvestLevel(0)
.harvestTool(ToolType.PICKAXE)
.sound(SoundType.STONE)
);
this.setDefaultState(this.getStateContainer().getBaseState().with(FACING, Direction.NORTH));
}
@Override
public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context)
{
switch (state.get(FACING)) {
case SOUTH:
return SHAPE_S;
case WEST:
return SHAPE_W;
case EAST:
return SHAPE_E;
case NORTH:
return SHAPE_N;
default:
return SHAPE_N;
}
}
@Override
public boolean isNormalCube(BlockState state, IBlockReader worldIn, BlockPos pos)
{
return false;
}
@Override
public BlockState getStateForPlacement(BlockItemUseContext context)
{
return this.getDefaultState().with(FACING, context.getPlacementHorizontalFacing().getOpposite());
}
@Override
public BlockState rotate(BlockState state, Rotation rot)
{
return state.with(FACING, rot.rotate(state.get(FACING)));
}
@Override
public BlockState mirror(BlockState state, Mirror mirrorIn)
{
return state.rotate(mirrorIn.toRotation(state.get(FACING)));
}
@Override
protected void fillStateContainer(StateContainer.Builder<Block, BlockState> builder)
{
builder.add(FACING);
}
}
This my code, i use VoxelShape to create my figure.