Add back datapack reload time tracking during world creation
This commit is contained in:
parent
9ad807ed8a
commit
64ee2d2914
|
|
@ -0,0 +1,35 @@
|
||||||
|
package org.embeddedt.modernfix.common.mixin.feature.measure_time;
|
||||||
|
|
||||||
|
import com.google.common.base.Stopwatch;
|
||||||
|
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
||||||
|
import com.llamalad7.mixinextras.sugar.Share;
|
||||||
|
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
|
||||||
|
import net.minecraft.server.WorldLoader;
|
||||||
|
import org.embeddedt.modernfix.ModernFix;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
@Mixin(WorldLoader.class)
|
||||||
|
public class WorldLoaderMixin {
|
||||||
|
@Inject(method = "load", at = @At("HEAD"))
|
||||||
|
private static void startStopwatch(CallbackInfoReturnable<CompletableFuture<?>> cir, @Share("stopwatch") LocalRef<Stopwatch> stopwatch) {
|
||||||
|
stopwatch.set(Stopwatch.createStarted());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ModifyReturnValue(method = "load", at = @At("RETURN"))
|
||||||
|
private static CompletableFuture<?> finishStopwatch(CompletableFuture<?> original, @Share("stopwatch") LocalRef<Stopwatch> stopwatch) {
|
||||||
|
Stopwatch watch = stopwatch.get();
|
||||||
|
if (watch != null) {
|
||||||
|
return original.whenComplete((o, throwable) -> {
|
||||||
|
watch.stop();
|
||||||
|
ModernFix.LOGGER.warn("Initial datapack load took {}", watch);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return original;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user