Search in sources :

Example 1 with IBakedModel

use of net.minecraft.client.renderer.model.IBakedModel 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 IBakedModel

use of net.minecraft.client.renderer.model.IBakedModel in project Overloaded by CJ-MC-Mods.

the class RenderMultiToolAssist method renderRemovePreview.

private static void renderRemovePreview(RenderWorldLastEvent event, BlockRayTraceResult result) {
    IBakedModel bakeModel = Minecraft.getInstance().getModelManager().getModel(new ModelResourceLocation(MODID + ":remove_preview", ""));
    BlockPos toRenderAt = result.getBlockPos();
    renderBlockModel(event, toRenderAt, bakeModel, Blocks.COBBLESTONE.defaultBlockState());
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation)

Example 3 with IBakedModel

use of net.minecraft.client.renderer.model.IBakedModel in project Overloaded by CJ-MC-Mods.

the class ClientProxy method bakeModelAndPut.

private static void bakeModelAndPut(ResourceLocation raw, ResourceLocation baked, ModelBakeEvent event) {
    IUnbakedModel unbakedModel = event.getModelLoader().getModel(raw);
    IBakedModel bakedModel = unbakedModel.bake(event.getModelLoader(), ModelLoader.defaultTextureGetter(), ModelRotation.X0_Y0, baked);
    event.getModelRegistry().put(baked, bakedModel);
}
Also used : IUnbakedModel(net.minecraft.client.renderer.model.IUnbakedModel) IBakedModel(net.minecraft.client.renderer.model.IBakedModel)

Example 4 with IBakedModel

use of net.minecraft.client.renderer.model.IBakedModel in project Overloaded by CJ-MC-Mods.

the class RenderMultiToolAssist method renderBlockPreview.

private static void renderBlockPreview(RenderWorldLastEvent event, BlockRayTraceResult result, @Nonnull BlockState state) {
    IBakedModel model = Minecraft.getInstance().getBlockRenderer().getBlockModel(state);
    BlockPos toRenderAt = result.getBlockPos().offset(result.getDirection().getNormal());
    renderBlockModel(event, toRenderAt, model, state);
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.model.IBakedModel)

Example 5 with IBakedModel

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

the class MimicModelHandler method onModelBake.

@SubscribeEvent
public static void onModelBake(ModelBakeEvent event) {
    MimicBlock quartzOreBlock = (MimicBlock) NetherExBlocks.QUARTZ_ORE.get();
    if (quartzOreBlock != null) {
        ModelResourceLocation modelLocation = quartzOreBlock.getModelLocation();
        IBakedModel model = event.getModelRegistry().get(modelLocation);
        if (model != null) {
            event.getModelRegistry().put(modelLocation, new MimicBakedModel(model, quartzOreBlock.getMimicType()));
        }
    }
}
Also used : MimicBlock(logictechcorp.libraryex.block.MimicBlock) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) MimicBakedModel(logictechcorp.libraryex.client.render.model.MimicBakedModel) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

IBakedModel (net.minecraft.client.renderer.model.IBakedModel)7 IVertexBuilder (com.mojang.blaze3d.vertex.IVertexBuilder)3 BlockPos (net.minecraft.util.math.BlockPos)3 BlockRendererDispatcher (net.minecraft.client.renderer.BlockRendererDispatcher)2 RenderType (net.minecraft.client.renderer.RenderType)2 ModelResourceLocation (net.minecraft.client.renderer.model.ModelResourceLocation)2 Random (java.util.Random)1 MimicBlock (logictechcorp.libraryex.block.MimicBlock)1 MimicBakedModel (logictechcorp.libraryex.client.render.model.MimicBakedModel)1 BlockState (net.minecraft.block.BlockState)1 IUnbakedModel (net.minecraft.client.renderer.model.IUnbakedModel)1 Direction (net.minecraft.util.Direction)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)1