use of org.bleachhack.event.events.EventRenderFluid 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;
}
Aggregations