use of com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer in project Create by Creators-of-Create.
the class WorldSectionElement method buildStructureBuffer.
private SuperByteBuffer buildStructureBuffer(PonderWorld world, RenderType layer) {
BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get();
PoseStack poseStack = objects.poseStack;
Random random = objects.random;
ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
ShadeSeparatedBufferBuilder builder = new ShadeSeparatedBufferBuilder(512);
BufferBuilder unshadedBuilder = objects.unshadedBuilder;
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
unshadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
shadeSeparatingWrapper.prepare(builder, unshadedBuilder);
world.setMask(this.section);
ForgeHooksClient.setRenderType(layer);
ModelBlockRenderer.enableCaching();
section.forEach(pos -> {
BlockState state = world.getBlockState(pos);
FluidState fluidState = world.getFluidState(pos);
poseStack.pushPose();
poseStack.translate(pos.getX(), pos.getY(), pos.getZ());
if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
BlockEntity tileEntity = world.getBlockEntity(pos);
dispatcher.renderBatched(state, pos, world, poseStack, shadeSeparatingWrapper, true, random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
}
if (!fluidState.isEmpty() && ItemBlockRenderTypes.canRenderInLayer(fluidState, layer))
dispatcher.renderLiquid(pos, world, builder, fluidState);
poseStack.popPose();
});
ModelBlockRenderer.clearCache();
ForgeHooksClient.setRenderType(null);
world.clearMask();
shadeSeparatingWrapper.clear();
unshadedBuilder.end();
builder.appendUnshadedVertices(unshadedBuilder);
builder.end();
return new SuperByteBuffer(builder);
}
use of com.jozufozu.flywheel.core.model.ShadeSeparatingVertexConsumer in project Create by Creators-of-Create.
the class SchematicRenderer method drawLayer.
protected SuperByteBuffer drawLayer(RenderType layer) {
BlockRenderDispatcher dispatcher = ModelUtil.VANILLA_RENDERER;
ThreadLocalObjects objects = THREAD_LOCAL_OBJECTS.get();
PoseStack poseStack = objects.poseStack;
Random random = objects.random;
BlockPos.MutableBlockPos mutableBlockPos = objects.mutableBlockPos;
SchematicWorld renderWorld = schematic;
BoundingBox bounds = renderWorld.getBounds();
ShadeSeparatingVertexConsumer shadeSeparatingWrapper = objects.shadeSeparatingWrapper;
ShadeSeparatedBufferBuilder builder = new ShadeSeparatedBufferBuilder(512);
BufferBuilder unshadedBuilder = objects.unshadedBuilder;
builder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
unshadedBuilder.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.BLOCK);
shadeSeparatingWrapper.prepare(builder, unshadedBuilder);
ForgeHooksClient.setRenderType(layer);
ModelBlockRenderer.enableCaching();
for (BlockPos localPos : BlockPos.betweenClosed(bounds.minX(), bounds.minY(), bounds.minZ(), bounds.maxX(), bounds.maxY(), bounds.maxZ())) {
BlockPos pos = mutableBlockPos.setWithOffset(localPos, anchor);
BlockState state = renderWorld.getBlockState(pos);
poseStack.pushPose();
poseStack.translate(localPos.getX(), localPos.getY(), localPos.getZ());
if (state.getRenderShape() == RenderShape.MODEL && ItemBlockRenderTypes.canRenderInLayer(state, layer)) {
BlockEntity tileEntity = renderWorld.getBlockEntity(localPos);
dispatcher.renderBatched(state, pos, renderWorld, poseStack, shadeSeparatingWrapper, true, random, tileEntity != null ? tileEntity.getModelData() : EmptyModelData.INSTANCE);
}
poseStack.popPose();
}
ModelBlockRenderer.clearCache();
ForgeHooksClient.setRenderType(null);
shadeSeparatingWrapper.clear();
unshadedBuilder.end();
builder.appendUnshadedVertices(unshadedBuilder);
builder.end();
return new SuperByteBuffer(builder);
}
Aggregations