Search in sources :

Example 1 with EnumBlockRenderType

use of net.minecraft.util.EnumBlockRenderType in project MC-Prefab by Brian-Wuest.

the class StructureRenderHandler method renderBlockBrightness.

public static void renderBlockBrightness(IBlockState state, float brightness) {
    BlockRendererDispatcher brd = Minecraft.getMinecraft().getBlockRendererDispatcher();
    EnumBlockRenderType enumblockrendertype = state.getRenderType();
    if (enumblockrendertype != EnumBlockRenderType.INVISIBLE) {
        switch(enumblockrendertype) {
            case MODEL:
            case ENTITYBLOCK_ANIMATED:
                {
                    // Only use the chest renderer if this is actually an instance of a chest.
                    if (enumblockrendertype == EnumBlockRenderType.ENTITYBLOCK_ANIMATED && state.getBlock() instanceof BlockChest) {
                        StructureRenderHandler.chestRenderer.renderChestBrightness(state.getBlock(), brightness);
                        break;
                    }
                    IBakedModel ibakedmodel = brd.getModelForState(state);
                    BlockModelRenderer renderer = brd.getBlockModelRenderer();
                    try {
                        renderer.renderModelBrightness(ibakedmodel, state, brightness, true);
                    } catch (Exception ex) {
                        // Don't do anything if a mod broke this vanilla block rendering. It just won't show up during the preview then.
                        int test = 1;
                        test = 2;
                    }
                    break;
                }
            default:
                {
                    break;
                }
        }
    }
}
Also used : BlockChest(net.minecraft.block.BlockChest) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType)

Example 2 with EnumBlockRenderType

use of net.minecraft.util.EnumBlockRenderType in project RFTools by McJty.

the class ElevatorTESR method renderBlock.

private static boolean renderBlock(BlockRendererDispatcher dispatcher, IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder worldRendererIn) {
    try {
        EnumBlockRenderType enumblockrendertype = state.getRenderType();
        if (enumblockrendertype == EnumBlockRenderType.INVISIBLE) {
            return false;
        } else {
            if (blockAccess.getWorldType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
                try {
                    state = state.getActualState(blockAccess, pos);
                } catch (Exception var8) {
                }
            }
            switch(enumblockrendertype) {
                case MODEL:
                    IBakedModel model = dispatcher.getModelForState(state);
                    state = state.getBlock().getExtendedState(state, blockAccess, pos);
                    return dispatcher.getBlockModelRenderer().renderModel(blockAccess, model, state, pos, worldRendererIn, false);
                case ENTITYBLOCK_ANIMATED:
                    return false;
                default:
                    return false;
            }
        }
    } catch (Throwable throwable) {
        CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block in world");
        CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being tesselated");
        CrashReportCategory.addBlockInfo(crashreportcategory, pos, state.getBlock(), state.getBlock().getMetaFromState(state));
        throw new ReportedException(crashreport);
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ReportedException(net.minecraft.util.ReportedException) CrashReportCategory(net.minecraft.crash.CrashReportCategory) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) ReportedException(net.minecraft.util.ReportedException)

Example 3 with EnumBlockRenderType

use of net.minecraft.util.EnumBlockRenderType in project EnderIO by SleepyTrousers.

the class IoConfigRenderer method renderBlock.

public void renderBlock(@Nonnull IBlockState state, @Nonnull BlockPos pos, @Nonnull IBlockAccess blockAccess, @Nonnull BufferBuilder worldRendererIn) {
    try {
        BlockRendererDispatcher blockrendererdispatcher = mc.getBlockRendererDispatcher();
        EnumBlockRenderType type = state.getRenderType();
        if (type != EnumBlockRenderType.MODEL) {
            blockrendererdispatcher.renderBlock(state, pos, blockAccess, worldRendererIn);
            return;
        }
        // We only want to change one param here, the check sides
        IBakedModel ibakedmodel = blockrendererdispatcher.getModelForState(state);
        state = state.getBlock().getExtendedState(state, world, pos);
        blockrendererdispatcher.getBlockModelRenderer().renderModel(blockAccess, ibakedmodel, state, pos, worldRendererIn, false);
    } catch (Throwable throwable) {
    // Just bury a render issue here, it is only the IO screen
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType)

Example 4 with EnumBlockRenderType

use of net.minecraft.util.EnumBlockRenderType in project Random-Things by lumien231.

the class AsmHandler method renderBlock.

@SideOnly(Side.CLIENT)
public static int renderBlock(BlockRendererDispatcher dispatcher, IBlockState state, BlockPos pos, IBlockAccess blockAccess, BufferBuilder worldRendererIn) {
    synchronized (TileEntityLightRedirector.redirectorSet) {
        if (!TileEntityLightRedirector.redirectorSet.isEmpty()) {
            blockAccess = Minecraft.getMinecraft().world;
            BlockPos changedPos = getSwitchedPosition(blockAccess, pos);
            posSet.clear();
            if (!changedPos.equals(pos)) {
                state = blockAccess.getBlockState(changedPos);
                try {
                    EnumBlockRenderType enumblockrendertype = state.getRenderType();
                    if (enumblockrendertype == EnumBlockRenderType.INVISIBLE) {
                    } else {
                        if (blockAccess.getWorldType() != WorldType.DEBUG_ALL_BLOCK_STATES) {
                            try {
                                state = state.getActualState(blockAccess, changedPos);
                            } catch (Exception var8) {
                                ;
                            }
                        }
                        switch(enumblockrendertype) {
                            case MODEL:
                                IBakedModel model = dispatcher.getModelForState(state);
                                state = state.getBlock().getExtendedState(state, blockAccess, changedPos);
                                return dispatcher.getBlockModelRenderer().renderModel(blockAccess, model, state, pos, worldRendererIn, true) ? 1 : 0;
                            case ENTITYBLOCK_ANIMATED:
                                return 0;
                            case LIQUID:
                                return 2;
                            default:
                                return 0;
                        }
                    }
                } catch (Throwable throwable) {
                    CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Tesselating block in world");
                    CrashReportCategory crashreportcategory = crashreport.makeCategory("Block being tesselated");
                    CrashReportCategory.addBlockInfo(crashreportcategory, pos, state.getBlock(), state.getBlock().getMetaFromState(state));
                    throw new ReportedException(crashreport);
                }
                return 0;
            }
        }
        return 2;
    }
}
Also used : CrashReport(net.minecraft.crash.CrashReport) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) ReportedException(net.minecraft.util.ReportedException) CrashReportCategory(net.minecraft.crash.CrashReportCategory) EnumBlockRenderType(net.minecraft.util.EnumBlockRenderType) ReportedException(net.minecraft.util.ReportedException) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)4 EnumBlockRenderType (net.minecraft.util.EnumBlockRenderType)4 CrashReport (net.minecraft.crash.CrashReport)2 CrashReportCategory (net.minecraft.crash.CrashReportCategory)2 ReportedException (net.minecraft.util.ReportedException)2 BlockChest (net.minecraft.block.BlockChest)1 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)1 BlockPos (net.minecraft.util.math.BlockPos)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1