Search in sources :

Example 1 with RenderShape

use of net.minecraft.world.level.block.RenderShape in project MC-Prefab by Brian-Wuest.

the class StructureRenderHandler method renderComponentInWorld.

private static boolean renderComponentInWorld(Level world, BuildBlock buildBlock, MultiBufferSource.BufferSource entityVertexConsumer, PoseStack matrixStack, BlockPos pos) {
    // Don't render this block if it's going to overlay a non-air/water block.
    BlockState targetBlock = world.getBlockState(pos);
    if (targetBlock.getMaterial() != Material.AIR && targetBlock.getMaterial() != Material.WATER) {
        return false;
    }
    StructureRenderHandler.doRenderComponent(world, buildBlock, pos, entityVertexConsumer, matrixStack);
    if (buildBlock.getSubBlock() != null) {
        Block foundBlock = Registry.BLOCK.get(buildBlock.getSubBlock().getResourceLocation());
        BlockState blockState = foundBlock.defaultBlockState();
        BuildBlock subBlock = BuildBlock.SetBlockState(StructureRenderHandler.currentConfiguration, StructureRenderHandler.currentConfiguration.pos, buildBlock.getSubBlock(), foundBlock, blockState, StructureRenderHandler.currentStructure.getClearSpace().getShape().getDirection());
        BlockPos subBlockPos = subBlock.getStartingPosition().getRelativePosition(StructureRenderHandler.currentConfiguration.pos, StructureRenderHandler.currentStructure.getClearSpace().getShape().getDirection(), StructureRenderHandler.currentConfiguration.houseFacing);
        RenderShape subBlockRenderType = subBlock.getBlockState().getRenderShape();
        return StructureRenderHandler.renderComponentInWorld(world, subBlock, entityVertexConsumer, matrixStack, subBlockPos);
    }
    return true;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) RenderShape(net.minecraft.world.level.block.RenderShape) BuildBlock(com.wuest.prefab.structures.base.BuildBlock) BuildBlock(com.wuest.prefab.structures.base.BuildBlock) Block(net.minecraft.world.level.block.Block) BlockPos(net.minecraft.core.BlockPos)

Aggregations

BuildBlock (com.wuest.prefab.structures.base.BuildBlock)1 BlockPos (net.minecraft.core.BlockPos)1 Block (net.minecraft.world.level.block.Block)1 RenderShape (net.minecraft.world.level.block.RenderShape)1 BlockState (net.minecraft.world.level.block.state.BlockState)1