Search in sources :

Example 1 with BakedQuad

use of net.minecraft.client.render.model.BakedQuad in project fabric by FabricMC.

the class TerrainFallbackConsumer method accept.

@Override
public void accept(BakedModel model) {
    final Supplier<Random> random = blockInfo.randomSupplier;
    final Value defaultMaterial = blockInfo.defaultAo && model.useAmbientOcclusion() ? MATERIAL_SHADED : MATERIAL_FLAT;
    final BlockState blockState = blockInfo.blockState;
    for (int i = 0; i < 6; i++) {
        Direction face = ModelHelper.faceFromIndex(i);
        List<BakedQuad> quads = model.getQuads(blockState, face, random.get());
        final int count = quads.size();
        if (count != 0 && blockInfo.shouldDrawFace(face)) {
            for (int j = 0; j < count; j++) {
                BakedQuad q = quads.get(j);
                renderQuad(q, face, defaultMaterial);
            }
        }
    }
    List<BakedQuad> quads = model.getQuads(blockState, null, random.get());
    final int count = quads.size();
    if (count != 0) {
        for (int j = 0; j < count; j++) {
            BakedQuad q = quads.get(j);
            renderQuad(q, null, defaultMaterial);
        }
    }
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) Value(net.fabricmc.indigo.renderer.RenderMaterialImpl.Value) Direction(net.minecraft.util.math.Direction)

Example 2 with BakedQuad

use of net.minecraft.client.render.model.BakedQuad in project sodium-fabric by CaffeineMC.

the class ChunkBlockRenderPipeline method renderModel.

public boolean renderModel(BlockRenderView world, BakedModel model, BlockState state, BlockPos pos, Vector3f translation, VertexConsumer builder, boolean cull, Random random, long seed) {
    LightPipeline lighter = this.getLightPipeline(state, model);
    lighter.reset();
    this.cachedColors.clear();
    Vec3d blockOffset = state.getOffsetPos(world, pos);
    translation.add((float) blockOffset.getX(), (float) blockOffset.getY(), (float) blockOffset.getZ());
    boolean rendered = false;
    for (Direction dir : DirectionUtil.ALL_DIRECTIONS) {
        random.setSeed(seed);
        List<BakedQuad> sided = model.getQuads(state, dir, random);
        if (sided.isEmpty()) {
            continue;
        }
        if (!cull || this.occlusionCache.shouldDrawSide(state, world, pos, dir)) {
            this.renderQuadList(world, state, pos, lighter, translation, builder, sided, dir);
            rendered = true;
        }
    }
    random.setSeed(seed);
    List<BakedQuad> all = model.getQuads(state, null, random);
    if (!all.isEmpty()) {
        this.renderQuadList(world, state, pos, lighter, translation, builder, all, null);
        rendered = true;
    }
    return rendered;
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) FlatLightPipeline(me.jellysquid.mods.sodium.client.render.light.flat.FlatLightPipeline) LightPipeline(me.jellysquid.mods.sodium.client.render.light.LightPipeline) SmoothLightPipeline(me.jellysquid.mods.sodium.client.render.light.smooth.SmoothLightPipeline) Direction(net.minecraft.util.math.Direction) Vec3d(net.minecraft.util.math.Vec3d)

Example 3 with BakedQuad

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

the class FallbackConsumer method accept.

@Override
public void accept(BakedModel model) {
    final Supplier<Random> random = blockInfo.randomSupplier;
    final boolean useAo = blockInfo.defaultAo && model.useAmbientOcclusion();
    final BlockState blockState = blockInfo.blockState;
    for (int i = 0; i < 6; i++) {
        final Direction face = ModelHelper.faceFromIndex(i);
        final List<BakedQuad> quads = model.getQuads(blockState, face, random.get());
        final int count = quads.size();
        if (count != 0 && blockInfo.shouldDrawFace(i)) {
            for (int j = 0; j < count; j++) {
                final BakedQuad q = quads.get(j);
                final Value defaultMaterial = ((BakedQuadExt) q).canvas_disableDiffuse() ? (useAo ? MATERIAL_AO_FLAT : MATERIAL_FLAT) : (useAo ? MATERIAL_AO_SHADED : MATERIAL_SHADED);
                renderQuad(q, i, defaultMaterial);
            }
        }
    }
    final List<BakedQuad> quads = model.getQuads(blockState, null, random.get());
    final int count = quads.size();
    if (count != 0) {
        for (int j = 0; j < count; j++) {
            final BakedQuad q = quads.get(j);
            final Value defaultMaterial = ((BakedQuadExt) q).canvas_disableDiffuse() ? (useAo ? MATERIAL_AO_FLAT : MATERIAL_FLAT) : (useAo ? MATERIAL_AO_SHADED : MATERIAL_SHADED);
            renderQuad(q, ModelHelper.NULL_FACE_ID, defaultMaterial);
        }
    }
}
Also used : BakedQuad(net.minecraft.client.render.model.BakedQuad) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) Value(grondag.canvas.apiimpl.RenderMaterialImpl.Value) Direction(net.minecraft.util.math.Direction)

Example 4 with BakedQuad

use of net.minecraft.client.render.model.BakedQuad 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 5 with BakedQuad

use of net.minecraft.client.render.model.BakedQuad 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

BakedQuad (net.minecraft.client.render.model.BakedQuad)12 Direction (net.minecraft.util.math.Direction)6 Random (java.util.Random)4 BlockState (net.minecraft.block.BlockState)4 BakedModel (net.minecraft.client.render.model.BakedModel)4 Vec3d (net.minecraft.util.math.Vec3d)3 Value (grondag.canvas.apiimpl.RenderMaterialImpl.Value)1 CubeRenderStuff (io.github.coolmineman.bitsandchisels.duck.CubeRenderStuff)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1 Predicate (java.util.function.Predicate)1 Value (link.infra.indium.renderer.RenderMaterialImpl.Value)1 LightPipeline (me.jellysquid.mods.sodium.client.render.light.LightPipeline)1 LightResult (me.jellysquid.mods.sodium.client.render.light.LightResult)1 FlatLightPipeline (me.jellysquid.mods.sodium.client.render.light.flat.FlatLightPipeline)1 SmoothLightPipeline (me.jellysquid.mods.sodium.client.render.light.smooth.SmoothLightPipeline)1 MutableQuadView (net.fabricmc.fabric.api.renderer.v1.mesh.MutableQuadView)1 Value (net.fabricmc.indigo.renderer.RenderMaterialImpl.Value)1 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)1 BakedModelManager (net.minecraft.client.render.model.BakedModelManager)1 MultipartBakedModel (net.minecraft.client.render.model.MultipartBakedModel)1