Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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:

XlGiIoG.png

 

Example when looking at the extended model: H7F2P9R.png
 

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.