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;
}
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();
}
Aggregations