Jump to content

BlockState half


ppitu

Recommended Posts

How can I get from blockstate half?
I'm already geting facing and I can't take half.

 

 @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;
            }

    }

 

Link to comment
Share on other sites

What are you trying to create?

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Please post your code (the entire class).

I don’t think you need anything “half” in stairs.

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

2 hours ago, ppitu said:

builder.add(FACING);

Your block does not have a HALF property.

  • Like 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

As far as I can tell, you want to have a slab thats not symmetrical(rotation/facing).

So you need at least two properties, one of which being a facing property.

For further information, you can always look into the vanilla class(in 1.16.1: "SlabBlock.java")

Hope I could help you.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.