Search in sources :

Example 1 with RenderLayer

use of net.minecraft.client.render.RenderLayer in project BleachHack by BleachDrinker420.

the class MixinChunkRebuildTask method newRender.

private Set<BlockEntity> newRender(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, WorldChunk.CreationType.CHECK);
                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);
                }
                EventRenderFluid event = new EventRenderFluid(fluid, blockPos3, bufferBuilder);
                BleachHack.eventBus.post(event);
                if (event.isCancelled())
                    continue;
                if (blockRenderManager.renderFluid(blockPos3, chunkRendererRegion, bufferBuilder, 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);
                }
                EventRenderBlock.Tesselate event = new EventRenderBlock.Tesselate(blockState, blockPos3, matrixStack, bufferBuilder);
                BleachHack.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.setCameraPosition(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) 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) EventRenderBlock(org.bleachhack.event.events.EventRenderBlock) EventRenderFluid(org.bleachhack.event.events.EventRenderFluid) BlockPos(net.minecraft.util.math.BlockPos) BlockEntity(net.minecraft.block.entity.BlockEntity) HashSet(java.util.HashSet) FluidState(net.minecraft.fluid.FluidState)

Example 2 with RenderLayer

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

the class BannerBlockEntityRendererMixin method renderCrossbar.

private void renderCrossbar(BannerBlockEntity bannerBlockEntity, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
    matrixStack.push();
    BlockState blockState = bannerBlockEntity.getCachedState();
    matrixStack.translate(0.5D, -0.1666666716337204D, 0.5D);
    float h = -blockState.get(WallBannerBlock.FACING).asRotation();
    matrixStack.multiply(Vec3f.POSITIVE_Y.getDegreesQuaternion(h));
    matrixStack.translate(0.0D, -0.3125D, -0.4375D);
    matrixStack.push();
    matrixStack.scale(0.6666667F, -0.6666667F, -0.6666667F);
    VertexConsumer vertexConsumer = ModelLoader.BANNER_BASE.getVertexConsumer(vertexConsumerProvider, RenderLayer::getEntitySolid);
    this.crossbar.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)

Example 3 with RenderLayer

use of net.minecraft.client.render.RenderLayer in project Biome-Makeover by Lemonszz.

the class AltarBlockEntityRenderer method render.

@Override
public void render(AltarBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
    matrices.push();
    matrices.translate(0.5D, 0.75D, 0.5D);
    float ticks = (float) entity.ticks + tickDelta;
    matrices.translate(0.0D, 0.1F + MathHelper.sin(ticks * 0.1F) * 0.01F, 0.0D);
    float h;
    for (h = entity.currentAngle - entity.lastAngle; h >= 3.1415927F; h -= 6.2831855F) {
    }
    while (h < -3.1415927F) {
        h += 6.2831855F;
    }
    float k = entity.lastAngle + h * tickDelta;
    matrices.multiply(Vector3f.POSITIVE_Y.getRadialQuaternion(-k));
    matrices.multiply(Vector3f.POSITIVE_Z.getDegreesQuaternion(80.0F));
    float l = MathHelper.lerp(tickDelta, entity.pageAngle, entity.nextPageAngle);
    float m = MathHelper.fractionalPart(l + 0.25F) * 1.6F - 0.3F;
    float n = MathHelper.fractionalPart(l + 0.75F) * 1.6F - 0.3F;
    float o = MathHelper.lerp(tickDelta, entity.pageTurningSpeed, entity.nextPageTurningSpeed);
    this.book.setPageAngles(ticks, MathHelper.clamp(m, 0.0F, 1.0F), MathHelper.clamp(n, 0.0F, 1.0F), o);
    VertexConsumer vertexConsumer = BOOK_TEXTURE.getVertexConsumer(vertexConsumers, RenderLayer::getEntitySolid);
    this.book.method_24184(matrices, vertexConsumer, light, overlay, 1.0F, 1.0F, 1.0F, 1.0F);
    matrices.pop();
}
Also used : RenderLayer(net.minecraft.client.render.RenderLayer) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Example 4 with RenderLayer

use of net.minecraft.client.render.RenderLayer in project Biome-Makeover by Lemonszz.

the class TapestryBlockEntityRenderer method render.

public void render(TapestryBlockEntity tapestry, float f, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i, int j) {
    float scale = 0.666F;
    boolean inInventory = tapestry.getWorld() == null;
    matrixStack.push();
    long time;
    if (inInventory) {
        time = 0L;
        matrixStack.translate(0.5D, 0.5D, 0.5D);
        this.pillar.visible = true;
    } else {
        time = tapestry.getWorld().getTime();
        BlockState blockState = tapestry.getCachedState();
        float rotation;
        if (blockState.getBlock() instanceof TapestryWallBlock || blockState.getBlock() instanceof AdjudicatorTapestryWallBlock) {
            matrixStack.translate(0.5D, -0.1666666716337204D, 0.5D);
            rotation = -blockState.get(TapestryWallBlock.FACING).asRotation();
            matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
            matrixStack.translate(0.0D, -0.3125D, -0.4375D);
            this.pillar.visible = false;
        } else {
            matrixStack.translate(0.5D, 0.5D, 0.5D);
            rotation = (float) (-(Integer) blockState.get(TapestryBlock.ROTATION) * 360) / 16.0F;
            matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(rotation));
            this.pillar.visible = true;
        }
    }
    matrixStack.push();
    matrixStack.scale(scale, -scale, -scale);
    VertexConsumer vertexConsumer = ModelLoader.BANNER_BASE.getVertexConsumer(vertexConsumerProvider, RenderLayer::getEntitySolid);
    this.pillar.render(matrixStack, vertexConsumer, i, j);
    this.crossbar.render(matrixStack, vertexConsumer, i, j);
    BlockPos blockPos = tapestry.getPos();
    float n = ((float) Math.floorMod((long) (blockPos.getX() * 7 + blockPos.getY() * 9 + blockPos.getZ() * 13) + time, 100L) + f) / 100.0F;
    this.banner.pitch = (-0.0125F + 0.01F * MathHelper.cos(6.2831855F * n)) * 3.1415927F;
    this.banner.pivotY = -32.0F;
    renderTapestry(matrixStack, vertexConsumerProvider, i, j, this.banner, tapestry.getColor());
    matrixStack.pop();
    matrixStack.pop();
}
Also used : BlockState(net.minecraft.block.BlockState) AdjudicatorTapestryWallBlock(party.lemons.biomemakeover.block.AdjudicatorTapestryWallBlock) AdjudicatorTapestryWallBlock(party.lemons.biomemakeover.block.AdjudicatorTapestryWallBlock) TapestryWallBlock(party.lemons.biomemakeover.block.TapestryWallBlock) RenderLayer(net.minecraft.client.render.RenderLayer) VertexConsumer(net.minecraft.client.render.VertexConsumer) BlockPos(net.minecraft.util.math.BlockPos)

Example 5 with RenderLayer

use of net.minecraft.client.render.RenderLayer in project Biome-Makeover by Lemonszz.

the class StoneGolemEntityRender method render.

@Override
public void render(StoneGolemEntity entity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
    matrixStack.push();
    boolean visible = this.isVisible(entity);
    boolean isInvis = !visible && !entity.isInvisibleTo(MinecraftClient.getInstance().player);
    boolean outline = MinecraftClient.getInstance().hasOutline(entity);
    matrixStack.scale(-1.0F, -1.0F, 1.0F);
    // ????
    matrixStack.translate(0.0D, -1.5010000467300415D, 0.0D);
    RenderLayer renderLayer = this.getRenderLayer(entity, visible, isInvis, outline);
    if (renderLayer != null) {
        VertexConsumer vertexConsumer = vertexConsumerProvider.getBuffer(renderLayer);
        int overlay = getOverlay(entity, this.getAnimationCounter(entity, g));
        getModel().renderBase(matrixStack, vertexConsumer, i, overlay, 1F, 1F, 1F, isInvis ? 0.15F : 1.0F);
    }
    matrixStack.pop();
    super.render(entity, f, g, matrixStack, vertexConsumerProvider, i);
}
Also used : RenderLayer(net.minecraft.client.render.RenderLayer) VertexConsumer(net.minecraft.client.render.VertexConsumer)

Aggregations

RenderLayer (net.minecraft.client.render.RenderLayer)15 BlockState (net.minecraft.block.BlockState)9 VertexConsumer (net.minecraft.client.render.VertexConsumer)7 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 BlockRenderManager (net.minecraft.client.render.block.BlockRenderManager)3 ChunkRendererRegion (net.minecraft.client.render.chunk.ChunkRendererRegion)3 HashSet (java.util.HashSet)2 Random (java.util.Random)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 RenderBlockEvent (com.tangykiwi.kiwiclient.event.RenderBlockEvent)1 RenderFluidEvent (com.tangykiwi.kiwiclient.event.RenderFluidEvent)1