Este repositório foi arquivado em 2025-08-14. Você pode visualizar arquivos e cloná-lo, mas não pode fazer alterações, tais como push, abrir issues, pull requests ou comentários.
DefaultComponents/src/main/java/com/awakenedredstone/defaultcomponents/mixin/ProfilerSystemMixin.java
2025-03-21 01:50:53 -03:00

30 linhas
1,2 KiB
Java

package com.awakenedredstone.defaultcomponents.mixin;
import com.llamalad7.mixinextras.sugar.Local;
import com.mojang.logging.LogUtils;
import net.minecraft.util.profiler.ProfileResult;
import net.minecraft.util.profiler.ProfilerSystem;
import org.slf4j.Logger;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(ProfilerSystem.class)
public class ProfilerSystemMixin {
@Shadow @Final private static Logger LOGGER;
@Shadow private String fullPath;
@Inject(method = "pop", at = @At(value = "INVOKE", target = "Ljava/lang/Math;min(JJ)J"))
private void logDebug(CallbackInfo ci, @Local(ordinal = 2) long time) {
if (Boolean.getBoolean("defaultcomponents.debug.reload")) {
LOGGER.info(
"'{}' took aprox {} ms",
LogUtils.defer(() -> ProfileResult.getHumanReadableName(this.fullPath)),
LogUtils.defer(() -> (double) time / 1000000.0)
);
}
}
}