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,

I am trying to create a transparent block.

It looks like previous version of minecraft supported the following code:

    @Override
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

But 1.18 does not seem to have those classes.

This is my class:

public class ActivatedDisappearBlock extends Block {
    public static final BooleanProperty IS_ACTIVATED = BooleanProperty.create("is_activated");

    public ActivatedDisappearBlock(Properties properties) {
        super(properties);
        registerDefaultState(defaultBlockState().setValue(IS_ACTIVATED, Boolean.valueOf(false)));
    }

    @Override
    protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
        super.createBlockStateDefinition(builder);
        builder.add(IS_ACTIVATED);
    }

    private boolean isVanished(BlockState state) {
        return state.hasProperty(IS_ACTIVATED) && state.getValue(IS_ACTIVATED);
    }

     // Compilation fails
    @Override
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

     // Compilation fails
    @Override
    public boolean isOpaqueCube(IBlockState state) {
        return false;
    }

    @Override
    public VoxelShape getShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) {
        return isVanished(state) ? Shapes.empty() : super.getShape(state, world, pos, ctx);
    }

    @Override
    public VoxelShape getCollisionShape(BlockState state, BlockGetter world, BlockPos pos, CollisionContext ctx) {
        return isVanished(state) ? Shapes.empty() : super.getCollisionShape(state, world, pos, ctx);
    }

    public void neighborChanged(BlockState blockState, Level level, BlockPos blockPos, Block blockIn, BlockPos fromPos, boolean isMoving) {
        if (!level.isClientSide) {
            System.out.println(blockState);
            if (blockIn instanceof ActivatorBlock){
                ActivatorBlock activator = (ActivatorBlock)blockIn;
                BlockState state = level.getBlockState(fromPos);
                var activating = state.getValue(IS_ACTIVATING);
                System.out.println(activating);
                blockState = blockState.setValue(IS_ACTIVATED, activating);
                level.setBlock(blockPos, blockState, 3);
                level.blockEntityChanged(blockPos);
                level.updateNeighbourForOutputSignal(blockPos, blockState.getBlock());
            }
        }
    }
}

 

Edited by Ideki
Cleanup

7 hours ago, Ideki said:

I am trying to create a transparent block.

You need to set the RenderLayer in FMLClientSetupEvent via ItemBlockRenderTypes#setRenderLayer 

  • Author

Thanks a lot.
I was able to figure out how to use the ItemBlockRenderTypes.setRenderLayer with your advice :)

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.