use of net.minecraft.util.profiler.Profiler in project sodium-fabric by CaffeineMC.
the class ChunkRenderManager method renderLayer.
public void renderLayer(RenderLayer renderLayer, MatrixStack matrixStack, double d, double e, double f) {
Profiler profiler = this.client.getProfiler();
renderLayer.startDrawing();
// TODO: resort transparent
// if (renderLayer == RenderLayer.getTranslucent()) {
// profiler.push("translucent_sort");
//
// double g = d - this.lastTranslucentSortX;
// double h = e - this.lastTranslucentSortY;
// double i = f - this.lastTranslucentSortZ;
//
// if (g * g + h * h + i * i > 1.0D) {
// this.lastTranslucentSortX = d;
// this.lastTranslucentSortY = e;
// this.lastTranslucentSortZ = f;
//
// int j = 0;
//
// for (ChunkGraphNode<T> chunkInfo : this.chunkGraph.getVisibleChunks()) {
// if (j < 15 && chunkInfo.chunk.scheduleSort(renderLayer, this.chunkBuilder)) {
// ++j;
// }
// }
// }
//
// profiler.pop();
// }
profiler.push("filterempty");
profiler.swap(() -> "render_" + renderLayer);
boolean notTranslucent = renderLayer != RenderLayer.getTranslucent();
ObjectListIterator<ChunkGraphNode<T>> it = this.chunkGraph.getVisibleChunks().listIterator(notTranslucent ? 0 : this.chunkGraph.getVisibleChunkCount());
this.chunkRenderer.begin();
while (true) {
if (notTranslucent) {
if (!it.hasNext()) {
break;
}
} else if (!it.hasPrevious()) {
break;
}
ChunkGraphNode<T> info = notTranslucent ? it.next() : it.previous();
ChunkRender<T> chunk = info.chunk;
T data = chunk.getRenderData();
if (data == null) {
continue;
}
if (chunk.getMeshInfo().containsLayer(renderLayer)) {
BlockPos origin = chunk.getOrigin();
matrixStack.push();
matrixStack.translate((double) origin.getX() - d, (double) origin.getY() - e, (double) origin.getZ() - f);
this.chunkRenderer.render(matrixStack, renderLayer, data);
matrixStack.pop();
}
}
this.chunkRenderer.end();
RenderSystem.clearCurrentColor();
profiler.pop();
renderLayer.endDrawing();
}
use of net.minecraft.util.profiler.Profiler in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class MultiModelArmorLayer method render.
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
Profiler profiler = MinecraftClient.getInstance().getProfiler();
profiler.push("littlemaidmodelloader:mm_armor_layer");
this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.HEAD);
this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.BODY);
this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.LEGS);
this.renderArmorPart(matrices, vertexConsumers, light, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, IHasMultiModel.Part.FEET);
profiler.pop();
}
use of net.minecraft.util.profiler.Profiler in project LittleMaidModelLoader-Fabric by SistrScarlet.
the class MultiModelLightLayer method render.
@Override
public void render(MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, T entity, float limbAngle, float limbDistance, float tickDelta, float animationProgress, float headYaw, float headPitch) {
Profiler profiler = MinecraftClient.getInstance().getProfiler();
profiler.push("littlemaidmodelloader:mm_eye_layer");
renderLightLayer(matrices, vertexConsumers, entity, limbAngle, limbDistance, tickDelta, animationProgress, headYaw, headPitch, entity.getCaps());
profiler.pop();
}
use of net.minecraft.util.profiler.Profiler in project roadrunner by MaxNeedsSnacks.
the class WorldMixin method postBlockEntityTick.
// Add any pending block entities to the world.
@Inject(method = "tickBlockEntities", at = @At("RETURN"))
private void postBlockEntityTick(CallbackInfo ci) {
Profiler profiler = this.profiler.get();
profiler.push("pendingBlockEntities$lithium");
this.blockEntities$lithium.checkOffThreadModifications(false);
this.pendingBlockEntities$lithium.checkOffThreadModifications(false);
// The overhead of this is essentially non-zero and doesn't matter in this code.
for (BlockEntity entity : this.pendingBlockEntities) {
if (entity.isRemoved()) {
continue;
}
// Try-add directly to avoid the double map lookup, helps speed things along
if (this.blockEntities$lithium.addIfAbsent(entity)) {
// vanilla has an extra updateListeners(...) call on the client here, but the one below should be enough
if (entity instanceof Tickable) {
this.tickingBlockEntities.add(entity);
}
BlockPos pos = entity.getPos();
World thisWorld = (World) (Object) this;
if (entity.getWorld() != thisWorld) {
entity.setLocation(thisWorld, pos);
}
entity.onLoad();
// Avoid the double chunk lookup (isLoaded followed by getChunk) by simply inlining getChunk call
// pass this.isClient instead of false, so the updateListeners call is always executed on the client (like vanilla)
Chunk chunk = this.getChunk(pos.getX() >> 4, pos.getZ() >> 4, ChunkStatus.FULL, this.isClient);
if (chunk != null) {
BlockState state = chunk.getBlockState(pos);
chunk.setBlockEntity(pos, entity);
this.updateListeners(pos, state, state, 3);
}
}
}
this.pendingBlockEntities.clear();
profiler.pop();
}
use of net.minecraft.util.profiler.Profiler in project SpeedRunIGT by RedLime.
the class MinecraftClientMixin method onInit.
/**
* Add import font system
*/
@Inject(method = "<init>", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/debug/DebugRenderer;<init>(Lnet/minecraft/client/MinecraftClient;)V", shift = At.Shift.BEFORE))
public void onInit(RunArgs args, CallbackInfo ci) {
this.resourceManager.registerListener(new SinglePreparationResourceReloadListener<Map<Identifier, List<Font>>>() {
@Override
protected Map<Identifier, List<Font>> prepare(ResourceManager manager, Profiler profiler) {
SpeedRunIGT.FONT_MAPS.clear();
try {
HashMap<Identifier, List<Font>> map = new HashMap<>();
File[] fontFiles = SpeedRunIGT.FONT_PATH.toFile().listFiles();
if (fontFiles == null)
return new HashMap<>();
for (File file : Arrays.stream(fontFiles).filter(file -> file.getName().endsWith(".ttf")).collect(Collectors.toList())) {
File config = SpeedRunIGT.FONT_PATH.resolve(file.getName().substring(0, file.getName().length() - 4) + ".json").toFile();
if (config.exists()) {
FontUtils.addFont(map, file, config);
} else {
FontUtils.addFont(map, file, null);
}
}
return map;
} catch (Throwable e) {
return new HashMap<>();
}
}
@Override
protected void apply(Map<Identifier, List<Font>> loader, ResourceManager manager, Profiler profiler) {
try {
FontManagerAccessor fontManager = (FontManagerAccessor) ((MinecraftClientAccessor) MinecraftClient.getInstance()).getFontManager();
for (Map.Entry<Identifier, List<Font>> listEntry : loader.entrySet()) {
FontStorage fontStorage = new FontStorage(fontManager.getTextureManager(), listEntry.getKey());
fontStorage.setFonts(listEntry.getValue());
fontManager.getFontStorages().put(listEntry.getKey(), fontStorage);
}
TimerDrawer.fontHeightMap.clear();
} catch (Throwable e) {
SpeedRunIGT.error("Error! failed import timer fonts!");
e.printStackTrace();
}
}
});
}
Aggregations