Search in sources :

Example 16 with RenderLayer

use of net.minecraft.client.render.RenderLayer in project KiwiClient by TangyKiwi.

the class ChunkRebuildTaskMixin method newRender2.

private Set<BlockEntity> newRender2(float cameraX, float cameraY, float cameraZ, ChunkData data, BlockBufferBuilderStorage buffers) {
    BlockPos blockPos = field_20839.getOrigin().toImmutable();
    BlockPos blockPos2 = blockPos.add(15, 15, 15);
    ChunkOcclusionDataBuilder chunkOcclusionDataBuilder = new ChunkOcclusionDataBuilder();
    Set<BlockEntity> set = new HashSet<>();
    ChunkRendererRegion chunkRendererRegion = this.region;
    this.region = null;
    MatrixStack matrixStack = new MatrixStack();
    if (chunkRendererRegion != null) {
        BlockModelRenderer.enableBrightnessCache();
        Random random = new Random();
        BlockRenderManager blockRenderManager = MinecraftClient.getInstance().getBlockRenderManager();
        for (BlockPos blockPos3 : BlockPos.iterate(blockPos, blockPos2)) {
            BlockState blockState = chunkRendererRegion.getBlockState(blockPos3);
            if (blockState.isOpaqueFullCube(chunkRendererRegion, blockPos3)) {
                chunkOcclusionDataBuilder.markClosed(blockPos3);
            }
            if (blockState.hasBlockEntity()) {
                BlockEntity blockEntityx = chunkRendererRegion.getBlockEntity(blockPos3);
                if (blockEntityx != null) {
                    this.addBlockEntity(data, set, blockEntityx);
                }
            }
            FluidState fluid = chunkRendererRegion.getFluidState(blockPos3);
            if (!fluid.isEmpty()) {
                RenderLayer renderLayer = RenderLayers.getFluidLayer(fluid);
                BufferBuilder bufferBuilder = buffers.get(renderLayer);
                if (data.initializedLayers.add(renderLayer)) {
                    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL);
                }
                RenderFluidEvent event = new RenderFluidEvent(fluid, blockPos3, bufferBuilder);
                KiwiClient.eventBus.post(event);
                if (event.isCancelled())
                    continue;
                if (blockRenderManager.renderFluid(blockPos3, chunkRendererRegion, bufferBuilder, blockState, fluid)) {
                    data.empty = false;
                    data.nonEmptyLayers.add(renderLayer);
                }
            }
            if (blockState.getRenderType() != BlockRenderType.INVISIBLE) {
                RenderLayer renderLayer = RenderLayers.getBlockLayer(blockState);
                BufferBuilder bufferBuilder = buffers.get(renderLayer);
                if (data.initializedLayers.add(renderLayer)) {
                    bufferBuilder.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_COLOR_TEXTURE_LIGHT_NORMAL);
                }
                RenderBlockEvent.Tesselate event = new RenderBlockEvent.Tesselate(blockState, blockPos3, matrixStack, bufferBuilder);
                KiwiClient.eventBus.post(event);
                if (event.isCancelled())
                    continue;
                matrixStack.push();
                matrixStack.translate(blockPos3.getX() & 15, blockPos3.getY() & 15, blockPos3.getZ() & 15);
                if (blockRenderManager.renderBlock(blockState, blockPos3, chunkRendererRegion, matrixStack, bufferBuilder, true, random)) {
                    data.empty = false;
                    data.nonEmptyLayers.add(renderLayer);
                }
                bufferBuilder.unfixColor();
                matrixStack.pop();
            }
        }
        if (data.nonEmptyLayers.contains(RenderLayer.getTranslucent())) {
            BufferBuilder bufferBuilder2 = buffers.get(RenderLayer.getTranslucent());
            bufferBuilder2.sortFrom(cameraX - (float) blockPos.getX(), cameraY - (float) blockPos.getY(), cameraZ - (float) blockPos.getZ());
            data.bufferState = bufferBuilder2.popState();
        }
        Stream<RenderLayer> var10000 = data.initializedLayers.stream();
        Objects.requireNonNull(buffers);
        var10000.map(buffers::get).forEach(BufferBuilder::end);
        BlockModelRenderer.disableBrightnessCache();
    }
    data.occlusionGraph = chunkOcclusionDataBuilder.build();
    return set;
}
Also used : ChunkRendererRegion(net.minecraft.client.render.chunk.ChunkRendererRegion) RenderFluidEvent(com.tangykiwi.kiwiclient.event.RenderFluidEvent) RenderBlockEvent(com.tangykiwi.kiwiclient.event.RenderBlockEvent) MatrixStack(net.minecraft.client.util.math.MatrixStack) BufferBuilder(net.minecraft.client.render.BufferBuilder) RenderLayer(net.minecraft.client.render.RenderLayer) ChunkOcclusionDataBuilder(net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder) BlockState(net.minecraft.block.BlockState) Random(java.util.Random) BlockRenderManager(net.minecraft.client.render.block.BlockRenderManager) BlockPos(net.minecraft.util.math.BlockPos) BlockEntity(net.minecraft.block.entity.BlockEntity) HashSet(java.util.HashSet) FluidState(net.minecraft.fluid.FluidState)

Example 17 with RenderLayer

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

the class BannerBlockEntityRendererMixin method renderPillar.

private void renderPillar(BannerBlockEntity bannerBlockEntity, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
    matrixStack.push();
    BlockState blockState = bannerBlockEntity.getCachedState();
    matrixStack.translate(0.5D, 0.5D, 0.5D);
    float h = (float) (-(Integer) blockState.get(BannerBlock.ROTATION) * 360) / 16.0F;
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(h));
    matrixStack.push();
    matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F);
    VertexConsumer vertexConsumer = ModelLoader.BANNER_BASE.getVertexConsumer(vertexConsumerProvider, RenderLayer::getEntitySolid);
    this.pillar.render(matrixStack, vertexConsumer, i, j);
    matrixStack.pop();
    matrixStack.pop();
}
Also used : BlockState(net.minecraft.block.BlockState) RenderLayer(net.minecraft.client.render.RenderLayer) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Aggregations

RenderLayer (net.minecraft.client.render.RenderLayer)17 BlockState (net.minecraft.block.BlockState)9 VertexConsumer (net.minecraft.client.render.VertexConsumer)9 BufferBuilder (net.minecraft.client.render.BufferBuilder)5 BlockPos (net.minecraft.util.math.BlockPos)5 BlockEntity (net.minecraft.block.entity.BlockEntity)4 ChunkOcclusionDataBuilder (net.minecraft.client.render.chunk.ChunkOcclusionDataBuilder)4 FluidState (net.minecraft.fluid.FluidState)4 Random (java.util.Random)3 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)3 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)3 HashSet (java.util.HashSet)2 CloneableBufferBuilder (me.jellysquid.mods.sodium.client.render.chunk.CloneableBufferBuilder)2 ChunkMeshBuilder (me.jellysquid.mods.sodium.client.render.mesh.ChunkMeshBuilder)2 BufferUploadData (me.jellysquid.mods.sodium.client.render.vertex.BufferUploadData)2 Block (net.minecraft.block.Block)2 MatrixStack (net.minecraft.client.util.math.MatrixStack)2 Vector3f (net.minecraft.client.util.math.Vector3f)2 Direction (net.minecraft.util.math.Direction)2 ForgeroToolItem (com.sigmundgranaas.forgero.item.ForgeroToolItem)1