If you need help with Bounding boxes

Started by shnoobins on

Topic category: Help with modding (Java Edition)

Last seen on 22:46, 19. Feb 2021
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
If you need help with Bounding boxes

I've searched around for awhile to figure out and solve the rotating bounding boxes not following the block in question..

this works within the 1.16.x environment unsure if it works for previous versions but here you go. 

 

just replace my examples of bounding box with yours using the VoxelShapes export within blockbench

 

                                                                protected static final VoxelShape SHAPE_W = Stream.of(
    
                                                                Block.makeCuboidShape(0.009999999999999787, 1, 8, 15.99, 3, 24),
                                                                Block.makeCuboidShape(0.009999999999999787, 1, -8, 15.99, 3, 8),
                                                                Block.makeCuboidShape(7, 4, 23.7, 9, 13, 24),
                                                                Block.makeCuboidShape(7, 4, -8.3, 9, 13, -8),
                                                                Block.makeCuboidShape(0, 13, 23.7, 16, 15, 24),
                                                                Block.makeCuboidShape(0, 13, -8.3, 16, 15, -8),
                                                                Block.makeCuboidShape(0, 0, -10, 16, 4, -6),
                                                                Block.makeCuboidShape(0, 0, 22, 16, 4, 26)
                                                                
    ).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();
                                                                
                                                                protected static final VoxelShape SHAPE_E = Stream.of(
    
                                                                Block.makeCuboidShape(0.009999999999999787, 1, 8, 15.99, 3, 24),
                                                                Block.makeCuboidShape(0.009999999999999787, 1, -8, 15.99, 3, 8),
                                                                Block.makeCuboidShape(7, 4, 23.7, 9, 13, 24),
                                                                Block.makeCuboidShape(7, 4, -8.3, 9, 13, -8),
                                                                Block.makeCuboidShape(0, 13, 23.7, 16, 15, 24),
                                                                Block.makeCuboidShape(0, 13, -8.3, 16, 15, -8),
                                                                Block.makeCuboidShape(0, 0, -10, 16, 4, -6),
                                                                Block.makeCuboidShape(0, 0, 22, 16, 4, 26)
                                                                
    ).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();

                                                                protected static final VoxelShape SHAPE_N = Stream.of(
    
                                                                Block.makeCuboidShape(8, 1, 0.01, 24, 3, 15.99),
                                                                Block.makeCuboidShape(-8, 1, 0.01, 8, 3, 15.99),
                                                                Block.makeCuboidShape(23.7, 4, 7, 24, 13, 9),
                                                                Block.makeCuboidShape(-8.3, 4, 7, -8, 13, 9),
                                                                Block.makeCuboidShape(23.7, 13, 0, 24, 15, 16),
                                                                Block.makeCuboidShape(-8.3, 13, 0, -8, 15, 16),
                                                                Block.makeCuboidShape(-10, 0, 0, -6, 4, 16),
                                                                Block.makeCuboidShape(22, 0, 0, 26, 4, 16)
                                                                
    ).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();

                                                                protected static final VoxelShape SHAPE_S = Stream.of(
    
                                                                Block.makeCuboidShape(8, 1, 0.01, 24, 3, 15.99),
                                                                Block.makeCuboidShape(-8, 1, 0.01, 8, 3, 15.99),
                                                                Block.makeCuboidShape(23.7, 4, 7, 24, 13, 9),
                                                                Block.makeCuboidShape(-8.3, 4, 7, -8, 13, 9),
                                                                Block.makeCuboidShape(23.7, 13, 0, 24, 15, 16),
                                                                Block.makeCuboidShape(-8.3, 13, 0, -8, 15, 16),
                                                                Block.makeCuboidShape(-10, 0, 0, -6, 4, 16),
                                                                Block.makeCuboidShape(22, 0, 0, 26, 4, 16)
                                                                
    ).reduce((v1, v2) -> {return VoxelShapes.combineAndSimplify(v1, v2, IBooleanFunction.OR);}).get();

@Override
    public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) {
            switch (state.get(FACING)) {
            case NORTH:
                return SHAPE_N;
            case SOUTH:
                return SHAPE_S;
            case EAST:
                return SHAPE_E;
            case WEST:
                return SHAPE_W;
            default:
                return SHAPE_W;
            }
        }