Posted December 16, 20222 yr Hello Forge Forums, I am currently trying to create essentially a "Giant Door", I have the model loading in correctly however the collision and interaction sizes/shapes do not reflect the shape of the model. Code: public class BlockGiantDoor extends BlockBasicGui<GiantDoorBlockEntity> { public BlockGiantDoor() { super(GiantDoorBlockEntity.class, BlockEntityRegistry.GIANT_DOOR, IBaseBlock.solid()); } @Override public InteractionResult use(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer, InteractionHand pHand, BlockHitResult pHit) { System.out.println("Clicked on giant door"); return InteractionResult.PASS; } @Override public RenderShape getRenderShape(BlockState pState) { return RenderShape.ENTITYBLOCK_ANIMATED; } @Override public VoxelShape getShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { //three blocks tall, two blocks wide, 1/8th of a block thick return Block.box(0, 0, 0, 32, 48, 2); } @Override public boolean hasDynamicShape() { return true; } @Override public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) { return this.getShape(pState, pLevel, pPos, pContext); } @Override public VoxelShape getInteractionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos) { return this.getShape(pState, pLevel, pPos, CollisionContext.empty()); } } public class GiantDoorBlockEntity extends BlockEntity implements IInventoryProvider, IAnimatable { private final AnimationFactory factory = GeckoLibUtil.createFactory(this); public GiantDoorBlockEntity(BlockPos pPos, BlockState pBlockState) { super(BlockEntityRegistry.GIANT_DOOR.get(), pPos, pBlockState); } @Override public Component getDisplayName() { return Component.literal("Giant Door"); } @Nullable @Override public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInventory, Player pPlayer) { return null; } @Override public void onRemove(BlockState pState, Level pLevel, BlockPos pPos, BlockState pNewState, boolean pIsMoving) { } @Override public void registerControllers(AnimationData animationData) { } @Override public AnimationFactory getFactory() { return factory; } } public class GiantDoorRenderer extends GeoBlockRenderer<GiantDoorBlockEntity> { public GiantDoorRenderer(BlockEntityRendererProvider.Context rendererProvider) { super(rendererProvider, AnimatedModel.block("giant_door")); } } The issue essentially is that players do not collide with the extended hit box, also they can only interact within the actual block position that the Giant Door was placed on, which does not reflect the correct size of the model. When looking at the original block position the model gets "outlined" just like a block would, and the hitbox appears to fit the model perfectly, however collision and using just seem to ignore this shape. Example when looking at the actual block position this was placed on: Example when looking at the extended model:
December 17, 20222 yr A block should never be larger than a block. If you want to do that, you will need to create a multipart block. You can see how this works with the regular door block. Since it seems like you are animating a geckolib model as well, you can make the model render over all the blocks using a master controller block entity with the rest being slaves/delegates, but each block individually needs to be separate.
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.