Search in sources :

Example 1 with BakedModel

use of net.minecraft.client.render.model.BakedModel in project canvas by vram-guild.

the class TerrainRenderContext method tesselateBlock.

/**
 * Called from chunk renderer hook.
 */
public void tesselateBlock(BlockState blockState, BlockPos blockPos) {
    try {
        final BakedModel model = blockRenderManager.getModel(blockState);
        aoCalc.clear();
        blockInfo.prepareForBlock(blockState, blockPos, model.useAmbientOcclusion());
        chunkInfo.beginBlock();
        ((DynamicBakedModel) model).emitBlockQuads(blockInfo.blockView, blockInfo.blockState, blockInfo.blockPos, blockInfo.randomSupplier, this);
    } catch (final Throwable var9) {
        final CrashReport crashReport_1 = CrashReport.create(var9, "Tesselating block in world - Canvas Renderer");
        final CrashReportSection crashReportElement_1 = crashReport_1.addElement("Block being tesselated");
        CrashReportSection.addBlockInfo(crashReportElement_1, blockPos, blockState);
        throw new CrashException(crashReport_1);
    }
}
Also used : CrashException(net.minecraft.util.crash.CrashException) DynamicBakedModel(grondag.frex.api.model.DynamicBakedModel) CrashReport(net.minecraft.util.crash.CrashReport) BakedModel(net.minecraft.client.render.model.BakedModel) DynamicBakedModel(grondag.frex.api.model.DynamicBakedModel) CrashReportSection(net.minecraft.util.crash.CrashReportSection)

Example 2 with BakedModel

use of net.minecraft.client.render.model.BakedModel in project meteor-client by MeteorDevelopment.

the class SimpleBlockRenderer method render.

public static void render(BlockPos pos, BlockState state, VertexConsumerProvider consumerProvider) {
    if (state.getRenderType() != BlockRenderType.MODEL)
        return;
    VertexConsumer consumer = consumerProvider.getBuffer(RenderLayer.getSolid());
    BakedModel model = mc.getBlockRenderManager().getModel(state);
    Vec3d offset = state.getModelOffset(mc.world, pos);
    double offsetX = pos.getX() + offset.x;
    double offsetY = pos.getY() + offset.y;
    double offsetZ = pos.getZ() + offset.z;
    // noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < DIRECTIONS.length; i++) {
        List<BakedQuad> list = model.getQuads(state, DIRECTIONS[i], RANDOM);
        if (!list.isEmpty())
            renderQuads(list, offsetX, offsetY, offsetZ, consumer);
    }
    List<BakedQuad> list = model.getQuads(state, null, RANDOM);
    if (!list.isEmpty())
        renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) BakedModel(net.minecraft.client.render.model.BakedModel) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with BakedModel

use of net.minecraft.client.render.model.BakedModel in project artifality by PinkGoosik.

the class ItemRendererMixin method twoModelsItemImplementation.

@Inject(method = "renderItem(Lnet/minecraft/entity/LivingEntity;Lnet/minecraft/item/ItemStack;Lnet/minecraft/client/render/model/json/ModelTransformation$Mode;ZLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;Lnet/minecraft/world/World;III)V", at = @At("HEAD"))
void twoModelsItemImplementation(LivingEntity entity, ItemStack stack, ModelTransformation.Mode renderMode, boolean leftHanded, MatrixStack matrices, VertexConsumerProvider vertexConsumers, World world, int light, int overlay, int seed, CallbackInfo ci) {
    if (!stack.isEmpty() && entity != null) {
        TwoModelsItemRegistry.ENTRIES.forEach((id, item) -> {
            if (stack.isOf(item)) {
                BakedModel model = models.getModelManager().getModel(new ModelIdentifier(id + "_in_hand#inventory"));
                renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
                matrices.scale(0, 0, 0);
            }
        });
    }
/*
        replaces the default enchanted book model
        with the custom one if a book has a lunar
        enchantment
        */
// if(!stack.isEmpty() && stack.isOf(Items.ENCHANTED_BOOK)) {
// NbtList enchantments = EnchantedBookItem.getEnchantmentNbt(stack);
// 
// for(int i = 0; i < enchantments.size(); ++i) {
// NbtCompound nbtCompound = enchantments.getCompound(i);
// 
// Registry.ENCHANTMENT.getOrEmpty(Identifier.tryParse(nbtCompound.getString("id"))).ifPresent((enchantment) -> {
// if(enchantment instanceof LunarEnchantment) {
// BakedModel model = models.getModelManager().getModel(new ModelIdentifier("artifality:lunar_enchanted_book#inventory"));
// renderItem(stack, renderMode, leftHanded, matrices, vertexConsumers, light, overlay, model);
// matrices.scale(0, 0, 0);
// }
// });
// }
// }
}
Also used : ModelIdentifier(net.minecraft.client.util.ModelIdentifier) BakedModel(net.minecraft.client.render.model.BakedModel)

Example 4 with BakedModel

use of net.minecraft.client.render.model.BakedModel in project friends-and-foes by Faboslav.

the class MoobloomFlowerFeatureRenderer method render.

public void render(MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int light, T moobloomEntity, float f, float g, float h, float j, float k, float l) {
    if (!moobloomEntity.isBaby() && !moobloomEntity.isInvisible()) {
        BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
        BlockState blockState = ModBlocks.BUTTERCUP.get().getDefaultState();
        int overlay = LivingEntityRenderer.getOverlay(moobloomEntity, 0.0F);
        MinecraftClient minecraftClient = MinecraftClient.getInstance();
        boolean renderAsModel = minecraftClient.hasOutline(moobloomEntity) && moobloomEntity.isInvisible();
        BakedModel bakedModel = blockRenderManager.getModel(blockState);
        // Head
        matrixStack.push();
        this.getContextModel().getHead().rotate(matrixStack);
        matrixStack.translate(0.09D, -0.6D, -0.185D);
        matrixStack.scale(-0.8F, -0.8F, 0.8F);
        matrixStack.translate(-0.5D, -0.5D, -0.5D);
        this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
        matrixStack.pop();
        // Body
        matrixStack.push();
        matrixStack.translate(0.22D, -0.28D, -0.06D);
        matrixStack.scale(-0.8F, -0.8F, 0.8F);
        matrixStack.translate(-0.5D, -0.5D, -0.5D);
        this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
        matrixStack.pop();
        matrixStack.push();
        matrixStack.translate(-0.2D, -0.22D, 0.01D);
        matrixStack.scale(-0.8F, -0.8F, 0.8F);
        matrixStack.translate(-0.5D, -0.5D, -0.5D);
        this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
        matrixStack.pop();
        matrixStack.push();
        matrixStack.translate(0.03D, -0.28D, 0.47D);
        matrixStack.scale(-0.8F, -0.8F, 0.8F);
        matrixStack.translate(-0.5D, -0.5D, -0.5D);
        this.renderFlower(matrixStack, vertexConsumerProvider, light, renderAsModel, blockRenderManager, blockState, overlay, bakedModel);
        matrixStack.pop();
    }
}
Also used : BlockState(net.minecraft.block.BlockState) BlockRenderManager(net.minecraft.client.render.block.BlockRenderManager) MinecraftClient(net.minecraft.client.MinecraftClient) BakedModel(net.minecraft.client.render.model.BakedModel)

Example 5 with BakedModel

use of net.minecraft.client.render.model.BakedModel in project Client by MatHax.

the class SimpleBlockRenderer method render.

public static void render(BlockPos pos, BlockState state, VertexConsumerProvider consumerProvider) {
    if (state.getRenderType() != BlockRenderType.MODEL)
        return;
    VertexConsumer consumer = consumerProvider.getBuffer(RenderLayer.getSolid());
    BakedModel model = mc.getBlockRenderManager().getModel(state);
    Vec3d offset = state.getModelOffset(mc.world, pos);
    double offsetX = pos.getX() + offset.x;
    double offsetY = pos.getY() + offset.y;
    double offsetZ = pos.getZ() + offset.z;
    // noinspection ForLoopReplaceableByForEach
    for (int i = 0; i < DIRECTIONS.length; i++) {
        List<BakedQuad> list = model.getQuads(state, DIRECTIONS[i], RANDOM);
        if (!list.isEmpty())
            renderQuads(list, offsetX, offsetY, offsetZ, consumer);
    }
    List<BakedQuad> list = model.getQuads(state, null, RANDOM);
    if (!list.isEmpty())
        renderQuads(list, offsetX, offsetY, offsetZ, consumer);
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) BakedModel(net.minecraft.client.render.model.BakedModel) Vec3d(net.minecraft.util.math.Vec3d)

Aggregations

BakedModel (net.minecraft.client.render.model.BakedModel)9 Vec3d (net.minecraft.util.math.Vec3d)4 BakedQuad (net.minecraft.client.render.model.BakedQuad)3 Block (net.minecraft.block.Block)2 SkullBlock (net.minecraft.block.SkullBlock)2 VoxelShape (net.minecraft.util.shape.VoxelShape)2 DynamicBakedModel (grondag.frex.api.model.DynamicBakedModel)1 Predicate (java.util.function.Predicate)1 EventHandler (mathax.client.eventbus.EventHandler)1 IItemEntity (mathax.client.mixininterface.IItemEntity)1 IItemEntity (meteordevelopment.meteorclient.mixininterface.IItemEntity)1 EventHandler (meteordevelopment.orbit.EventHandler)1 BlockState (net.minecraft.block.BlockState)1 MinecraftClient (net.minecraft.client.MinecraftClient)1 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)1 MultipartBakedModel (net.minecraft.client.render.model.MultipartBakedModel)1 JsonUnbakedModel (net.minecraft.client.render.model.json.JsonUnbakedModel)1 ModelOverride (net.minecraft.client.render.model.json.ModelOverride)1 ModelIdentifier (net.minecraft.client.util.ModelIdentifier)1 AliasedBlockItem (net.minecraft.item.AliasedBlockItem)1