Posted July 7, 20223 yr I've made a block with custom shapes and hitbox using VoxelShapes and when texting it in-game two problems became apparent. First of the lightning didn't work correctly as shown below: Light glitch And some wierd problem with the hitbox. The hitbox works fine except when you try to destroy or interact with the upper half of the block: Hitbox problem Below is the blocks class: package com.hivemind.superheated.block; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.world.item.context.BlockPlaceContext; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.LevelAccessor; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.HorizontalDirectionalBlock; import net.minecraft.world.level.block.Mirror; import net.minecraft.world.level.block.Rotation; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.StateDefinition.Builder; import net.minecraft.world.level.block.state.properties.DirectionProperty; import net.minecraft.world.phys.shapes.BooleanOp; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.Shapes; import net.minecraft.world.phys.shapes.VoxelShape; public class Forge extends Block{ public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; @Override public VoxelShape getShape( BlockState state, BlockGetter getter, BlockPos pos, CollisionContext context) { switch (state.getValue(FACING)) { case EAST: VoxelShape EAST = Shapes.empty(); EAST = Shapes.join(EAST, Shapes.box(0, 0, 0, 1, 0.0625, 1), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.25, 0.3125, 0.75, 0.875, 0.875, 0.9375), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.25, 0.3125, 0.0625, 0.875, 0.875, 0.25), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.25, 0.875, 0.0625, 0.875, 1, 0.9375), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.25, 0.0625, 0.0625, 0.875, 0.3125, 0.9375), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.0625, 0.0625, 0.0625, 0.25, 1, 0.9375), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0, 1, 0, 0.9375, 1.125, 1), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.0625, 1.125, 0.0625, 0.875, 1.375, 0.9375), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.0625, 1.375, 0.1875, 0.75, 1.625, 0.8125), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0.0625, 1.625, 0.3125, 0.625, 1.875, 0.6875), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0, 0.0625, 0.375, 0.0625, 1, 0.625), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0, 1.125, 0.375, 0.0625, 1.875, 0.625), BooleanOp.OR); EAST = Shapes.join(EAST, Shapes.box(0, 1.875, 0.375, 0.5, 2, 0.625), BooleanOp.OR); return EAST; case SOUTH: VoxelShape SOUTH =Shapes.empty(); SOUTH =Shapes.join(SOUTH,Shapes.box(0, 0, 0, 1, 0.0625, 1), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.0625, 0.3125, 0.25, 0.25, 0.875, 0.875), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.75, 0.3125, 0.25, 0.9375, 0.875, 0.875), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.0625, 0.875, 0.25, 0.9375, 1, 0.875), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.0625, 0.0625, 0.25, 0.9375, 0.3125, 0.875), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.0625, 0.0625, 0.0625, 0.9375, 1, 0.25), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0, 1, 0, 1, 1.125, 0.9375), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.0625, 1.125, 0.0625, 0.9375, 1.375, 0.875), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.1875, 1.375, 0.0625, 0.8125, 1.625, 0.75), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.3125, 1.625, 0.0625, 0.6875, 1.875, 0.625), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.375, 0.0625, 0, 0.625, 1, 0.0625), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.375, 1.125, 0, 0.625, 1.875, 0.0625), BooleanOp.OR); SOUTH =Shapes.join(SOUTH,Shapes.box(0.375, 1.875, 0, 0.625, 2, 0.5), BooleanOp.OR); return SOUTH; case WEST: VoxelShape WEST = Shapes.empty(); WEST = Shapes.join(WEST, Shapes.box(0, 0, 0, 1, 0.0625, 1), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.125, 0.3125, 0.0625, 0.75, 0.875, 0.25), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.125, 0.3125, 0.75, 0.75, 0.875, 0.9375), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.125, 0.875, 0.0625, 0.75, 1, 0.9375), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.125, 0.0625, 0.0625, 0.75, 0.3125, 0.9375), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.75, 0.0625, 0.0625, 0.9375, 1, 0.9375), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.0625, 1, 0, 1, 1.125, 1), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.125, 1.125, 0.0625, 0.9375, 1.375, 0.9375), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.25, 1.375, 0.1875, 0.9375, 1.625, 0.8125), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.375, 1.625, 0.3125, 0.9375, 1.875, 0.6875), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.9375, 0.0625, 0.375, 1, 1, 0.625), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.9375, 1.125, 0.375, 1, 1.875, 0.625), BooleanOp.OR); WEST = Shapes.join(WEST, Shapes.box(0.5, 1.875, 0.375, 1, 2, 0.625), BooleanOp.OR); return WEST; default: VoxelShape NORTH =Shapes.empty(); NORTH =Shapes.join(NORTH,Shapes.box(0, 0, 0, 1, 0.0625, 1), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.75, 0.3125, 0.125, 0.9375, 0.875, 0.75), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.0625, 0.3125, 0.125, 0.25, 0.875, 0.75), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.0625, 0.875, 0.125, 0.9375, 1, 0.75), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.0625, 0.0625, 0.125, 0.9375, 0.3125, 0.75), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.0625, 0.0625, 0.75, 0.9375, 1, 0.9375), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0, 1, 0.0625, 1, 1.125, 1), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.0625, 1.125, 0.125, 0.9375, 1.375, 0.9375), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.1875, 1.375, 0.25, 0.8125, 1.625, 0.9375), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.3125, 1.625, 0.375, 0.6875, 1.875, 0.9375), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.375, 0.0625, 0.9375, 0.625, 1, 1), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.375, 1.125, 0.9375, 0.625, 1.875, 1), BooleanOp.OR); NORTH =Shapes.join(NORTH,Shapes.box(0.375, 1.875, 0.5, 0.625, 2, 1), BooleanOp.OR); return NORTH; } } public Forge( Properties properties) { super(properties); this.registerDefaultState(this.defaultBlockState().setValue(FACING, Direction.NORTH)); } @Override protected void createBlockStateDefinition( Builder<Block, BlockState> builder) { builder.add(FACING); super.createBlockStateDefinition( builder); } @Override public BlockState getStateForPlacement(BlockPlaceContext context) { return this.defaultBlockState().setValue(FACING, context.getHorizontalDirection().getOpposite()); } @SuppressWarnings("deprecation") @Override public BlockState mirror(BlockState state, Mirror mirror) { return state.rotate(mirror.getRotation(state.getValue(FACING))); } @Override public BlockState rotate(BlockState state, LevelAccessor world, BlockPos pos, Rotation direction) { return state.setValue(FACING, direction.rotate(state.getValue(FACING))); } } If you need anything else to find the problem just ask.
July 8, 20223 yr Well. Yes. Blocks aren't meant to take up visual space outside their 1x1x1 cube. Two vanilla blocks have this issue as well. https://bugs.mojang.com/browse/MC-158827?filter=-2 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.
July 8, 20223 yr why did you not use two Blocks, this would fix the light issue? 15 hours ago, Hive Mind said: And some wierd problem with the hitbox. The hitbox works fine except when you try to destroy or interact with the upper half of the block as far as i know this is not a issue/bug But I'm not sure what exactly is the reason that you can't sneak along the edge of the block, I suspect that the hitbox area is not large enough for the player to stand on it
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.