Posted March 6, 20223 yr 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 March 6, 20223 yr by Ideki Cleanup
March 6, 20223 yr Author Or can I change the render type of my block to -1 as according to the following old documentation that would make it not rendered (like air). Minecraft Modding: Block Rendering [1.8] Edited March 6, 20223 yr by Ideki
March 7, 20223 yr 7 hours ago, Ideki said: I am trying to create a transparent block. You need to set the RenderLayer in FMLClientSetupEvent via ItemBlockRenderTypes#setRenderLayer
March 7, 20223 yr 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.