Search in sources :

Example 1 with RenderType

use of net.minecraft.client.renderer.RenderType in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method renderBlock.

/**
 * Renders a block state into the world. This only exists for optifine compatibility mode.
 *
 * @param state The state to render.
 * @param world The world context to render into.
 * @param pos The position of the block.
 * @param matrix The render matrix.
 * @param buffer The render buffer.
 */
private static void renderBlock(BlockState state, World world, BlockPos pos, MatrixStack matrix, IRenderTypeBuffer buffer) {
    final BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
    final IBakedModel model = dispatcher.getBlockModel(state);
    final boolean useAO = Minecraft.useAmbientOcclusion() && state.getLightValue(world, pos) == 0 && model.useAmbientOcclusion();
    final RenderType type = RenderUtils.findRenderType(state);
    if (type != null) {
        ForgeHooksClient.setRenderLayer(type);
        final IVertexBuilder builder = buffer.getBuffer(type);
        renderModel(dispatcher.getModelRenderer(), useAO, world, model, state, pos, matrix, builder, false, OverlayTexture.NO_OVERLAY);
        ForgeHooksClient.setRenderLayer(null);
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.model.IBakedModel) RenderType(net.minecraft.client.renderer.RenderType) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 2 with RenderType

use of net.minecraft.client.renderer.RenderType in project Bookshelf by Darkhax-Minecraft.

the class RenderUtils method renderBlock.

/**
 * Renders a block state into the world.
 *
 * @param state The state to render.
 * @param world The world context to render into.
 * @param pos The position of the block.
 * @param matrix The render matrix.
 * @param buffer The render buffer.
 * @param preferredSides The sides to render, allows faces to be culled.
 */
private static void renderBlock(BlockState state, World world, BlockPos pos, MatrixStack matrix, IRenderTypeBuffer buffer, Direction[] renderSides) {
    final BlockRendererDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
    final IBakedModel model = dispatcher.getBlockModel(state);
    final RenderType type = RenderUtils.findRenderType(state);
    if (type != null) {
        ForgeHooksClient.setRenderLayer(type);
        final IVertexBuilder builder = buffer.getBuffer(type);
        RenderUtils.renderModel(dispatcher.getModelRenderer(), world, model, state, pos, matrix, builder, renderSides);
        ForgeHooksClient.setRenderLayer(null);
    }
}
Also used : IBakedModel(net.minecraft.client.renderer.model.IBakedModel) RenderType(net.minecraft.client.renderer.RenderType) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) IVertexBuilder(com.mojang.blaze3d.vertex.IVertexBuilder)

Example 3 with RenderType

use of net.minecraft.client.renderer.RenderType in project MinecraftForge by MinecraftForge.

the class ItemLayerModel method bake.

@Override
public BakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, ModelState modelTransform, ItemOverrides overrides, ResourceLocation modelLocation) {
    ImmutableMap<ItemTransforms.TransformType, Transformation> transformMap = PerspectiveMapWrapper.getTransforms(new CompositeModelState(owner.getCombinedTransform(), modelTransform));
    Transformation transform = modelTransform.getRotation();
    TextureAtlasSprite particle = spriteGetter.apply(owner.isTexturePresent("particle") ? owner.resolveTexture("particle") : textures.get(0));
    ItemMultiLayerBakedModel.Builder builder = ItemMultiLayerBakedModel.builder(owner, particle, overrides, transformMap);
    for (int i = 0; i < textures.size(); i++) {
        TextureAtlasSprite tas = spriteGetter.apply(textures.get(i));
        boolean fullbright = fullbrightLayers.contains(i);
        RenderType rt = getLayerRenderType(fullbright);
        builder.addQuads(rt, getQuadsForSprite(i, tas, transform, fullbright));
    }
    return builder.build();
}
Also used : Transformation(com.mojang.math.Transformation) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) RenderType(net.minecraft.client.renderer.RenderType)

Example 4 with RenderType

use of net.minecraft.client.renderer.RenderType in project NetherEx by LogicTechCorp.

the class NetherEx method onClientSetup.

@OnlyIn(Dist.CLIENT)
private void onClientSetup(FMLClientSetupEvent event) {
    RenderType cutout = RenderType.getCutout();
    RenderTypeLookup.setRenderLayer(NetherExBlocks.QUARTZ_ORE.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.THORNSTALK.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.BROWN_ELDER_MUSHROOM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.RED_ELDER_MUSHROOM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_CAP.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_STEM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.BLUE_FIRE.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_CAP.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_STEM.get(), cutout);
    RenderType translucent = RenderType.getTranslucent();
    RenderTypeLookup.setRenderLayer(NetherExBlocks.FROSTBURN_ICE.get(), translucent);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.SOUL_GLASS.get(), translucent);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.SOUL_GLASS_PANE.get(), translucent);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.MOGUS.get(), MogusRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SALAMANDER.get(), SalamanderRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPINOUT.get(), SpinoutRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPORE.get(), SporeRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPORE_CREEPER.get(), SporeCreeperRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.WIGHT.get(), WightRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.COOLMAR_SPIDER.get(), CoolmarSpiderRenderer::new);
}
Also used : RenderType(net.minecraft.client.renderer.RenderType) OnlyIn(net.minecraftforge.api.distmarker.OnlyIn)

Example 5 with RenderType

use of net.minecraft.client.renderer.RenderType in project NetherEx by LogicTechCorp.

the class ClientProxy method onClientSetup.

private void onClientSetup(FMLClientSetupEvent event) {
    RenderType cutoutMipped = RenderType.getCutoutMipped();
    RenderType cutout = RenderType.getCutout();
    RenderTypeLookup.setRenderLayer(NetherExBlocks.QUARTZ_ORE.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.THORNSTALK.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.BROWN_ELDER_MUSHROOM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.RED_ELDER_MUSHROOM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_CAP.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_STEM.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.BLUE_FIRE.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_CAP.get(), cutout);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.ENOKI_MUSHROOM_STEM.get(), cutout);
    RenderType translucent = RenderType.getTranslucent();
    RenderTypeLookup.setRenderLayer(NetherExBlocks.FROSTBURN_ICE.get(), translucent);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.SOUL_GLASS.get(), translucent);
    RenderTypeLookup.setRenderLayer(NetherExBlocks.SOUL_GLASS_PANE.get(), translucent);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.MOGUS.get(), MogusRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SALAMANDER.get(), SalamanderRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPINOUT.get(), SpinoutRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPORE.get(), SporeRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.SPORE_CREEPER.get(), SporeCreeperRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.WIGHT.get(), WightRenderer::new);
    RenderingRegistry.registerEntityRenderingHandler(NetherExEntityTypes.COOLMAR_SPIDER.get(), CoolmarSpiderRenderer::new);
}
Also used : RenderType(net.minecraft.client.renderer.RenderType)

Aggregations

RenderType (net.minecraft.client.renderer.RenderType)5 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)2 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)2 IBakedModel (net.minecraft.client.renderer.model.IBakedModel)2 Transformation (com.mojang.math.Transformation)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 OnlyIn (net.minecraftforge.api.distmarker.OnlyIn)1