Merge remote-tracking branch 'origin/1.19.4' into 1.20
This commit is contained in:
commit
02fd57f9a4
|
|
@ -3,9 +3,6 @@ package org.embeddedt.modernfix;
|
|||
import com.mojang.datafixers.util.Pair;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.ConnectScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.gui.screens.TitleScreen;
|
||||
import net.minecraft.network.syncher.EntityDataAccessor;
|
||||
import net.minecraft.network.syncher.SynchedEntityData;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
|
@ -28,6 +25,7 @@ import java.util.*;
|
|||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class ModernFixClient {
|
||||
public static ModernFixClient INSTANCE;
|
||||
public static long worldLoadStartTime;
|
||||
private static int numRenderTicks;
|
||||
|
||||
|
|
@ -43,6 +41,7 @@ public class ModernFixClient {
|
|||
public static List<ModernFixClientIntegration> CLIENT_INTEGRATIONS = new CopyOnWriteArrayList<>();
|
||||
|
||||
public ModernFixClient() {
|
||||
INSTANCE = this;
|
||||
// clear reserve as it's not needed
|
||||
MemoryReserve.release();
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.branding.F3Screen")) {
|
||||
|
|
@ -66,16 +65,14 @@ public class ModernFixClient {
|
|||
tagsUpdated = false;
|
||||
}
|
||||
|
||||
public void onScreenOpening(Screen openingScreen) {
|
||||
if(openingScreen instanceof ConnectScreen) {
|
||||
worldLoadStartTime = System.nanoTime();
|
||||
} else if (openingScreen instanceof TitleScreen && gameStartTimeSeconds < 0) {
|
||||
gameStartTimeSeconds = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.GameLoad"))
|
||||
ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start");
|
||||
ModernFixPlatformHooks.INSTANCE.onLaunchComplete();
|
||||
ClassInfoManager.clear();
|
||||
}
|
||||
public void onGameLaunchFinish() {
|
||||
if(gameStartTimeSeconds >= 0)
|
||||
return;
|
||||
gameStartTimeSeconds = ManagementFactory.getRuntimeMXBean().getUptime() / 1000f;
|
||||
if(ModernFixMixinPlugin.instance.isOptionEnabled("feature.measure_time.GameLoad"))
|
||||
ModernFix.LOGGER.warn("Game took " + gameStartTimeSeconds + " seconds to start");
|
||||
ModernFixPlatformHooks.INSTANCE.onLaunchComplete();
|
||||
ClassInfoManager.clear();
|
||||
}
|
||||
|
||||
public void onRecipesUpdated() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package org.embeddedt.modernfix.common.mixin.feature.measure_time;
|
||||
|
||||
import net.minecraft.client.gui.screens.ConnectScreen;
|
||||
import org.embeddedt.modernfix.ModernFixClient;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
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.CallbackInfo;
|
||||
|
||||
@Mixin(ConnectScreen.class)
|
||||
@ClientOnlyMixin
|
||||
public class ConnectScreenMixin {
|
||||
@Inject(method = "connect", at = @At("HEAD"))
|
||||
private void recordConnectStartTime(CallbackInfo ci) {
|
||||
ModernFixClient.worldLoadStartTime = System.nanoTime();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
package org.embeddedt.modernfix.common.mixin.feature.measure_time;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Overlay;
|
||||
import org.embeddedt.modernfix.ModernFixClient;
|
||||
import org.embeddedt.modernfix.annotation.ClientOnlyMixin;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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;
|
||||
|
|
@ -12,20 +15,16 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||
@Mixin(Minecraft.class)
|
||||
@ClientOnlyMixin
|
||||
public class MinecraftMixin {
|
||||
/* not supported in 1.19
|
||||
private long datapackReloadStartTime;
|
||||
// TODO re-add datapack reload time measurement
|
||||
@Shadow @Nullable public Overlay overlay;
|
||||
|
||||
@Inject(method = "makeWorldStem(Lnet/minecraft/server/packs/repository/PackRepository;ZLnet/minecraft/server/WorldStem$DataPackConfigSupplier;Lnet/minecraft/server/WorldStem$WorldDataSupplier;)Lnet/minecraft/server/WorldStem;", at = @At(value = "HEAD"))
|
||||
private void recordReloadStart(CallbackInfoReturnable<WorldStem> cir) {
|
||||
datapackReloadStartTime = System.nanoTime();
|
||||
@Inject(method = "tick", at = @At("HEAD"))
|
||||
private void onClientTick(CallbackInfo ci) {
|
||||
if(this.overlay == null) {
|
||||
ModernFixClient.INSTANCE.onGameLaunchFinish();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "makeWorldStem(Lnet/minecraft/server/packs/repository/PackRepository;ZLnet/minecraft/server/WorldStem$DataPackConfigSupplier;Lnet/minecraft/server/WorldStem$WorldDataSupplier;)Lnet/minecraft/server/WorldStem;", at = @At(value = "RETURN"))
|
||||
private void recordReloadEnd(CallbackInfoReturnable<WorldStem> cir) {
|
||||
float timeSpentReloading = ((float)(System.nanoTime() - datapackReloadStartTime) / 1000000000f);
|
||||
ModernFix.LOGGER.warn("Datapack reload took " + timeSpentReloading + " seconds.");
|
||||
}
|
||||
*/
|
||||
@Inject(method = "doWorldLoad", at = @At("HEAD"))
|
||||
private void recordWorldLoadStart(CallbackInfo ci) {
|
||||
ModernFixClient.worldLoadStartTime = System.nanoTime();
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ dependencies {
|
|||
|
||||
modIncludeImplementation(fabricApi.module("fabric-api-base", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-lifecycle-events-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modImplementation(fabricApi.module("fabric-screen-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modIncludeImplementation(fabricApi.module("fabric-command-api-v2", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modImplementation(fabricApi.module("fabric-model-loading-api-v1", rootProject.fabric_api_version)) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
modCompileOnly(fabricApi.module("fabric-models-v0", "0.84.0+1.20.1")) { exclude group: 'net.fabricmc', module: 'fabric-loader' }
|
||||
|
|
|
|||
|
|
@ -2,14 +2,10 @@ package org.embeddedt.modernfix;
|
|||
|
||||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
|
||||
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
|
||||
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import org.embeddedt.modernfix.fabric.datagen.RuntimeDatagen;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class ModernFixClientFabric implements ClientModInitializer {
|
||||
public static ModernFixClient commonMod;
|
||||
|
||||
|
|
@ -18,16 +14,6 @@ public class ModernFixClientFabric implements ClientModInitializer {
|
|||
commonMod = new ModernFixClient();
|
||||
|
||||
ClientTickEvents.END_CLIENT_TICK.register((mc) -> commonMod.onRenderTickEnd());
|
||||
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
|
||||
AtomicBoolean hasOpened = new AtomicBoolean(false);
|
||||
ScreenEvents.beforeTick(screen).register(screen1 -> {
|
||||
if(Minecraft.getInstance().getOverlay() != null)
|
||||
return;
|
||||
if(!hasOpened.getAndSet(true)) {
|
||||
commonMod.onScreenOpening(screen1);
|
||||
}
|
||||
});
|
||||
});
|
||||
ServerLifecycleEvents.SERVER_STARTED.register(server -> {
|
||||
commonMod.onServerStarted(server);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@
|
|||
],
|
||||
"depends": {
|
||||
"fabric-lifecycle-events-v1": "*",
|
||||
"fabric-screen-api-v1": "*",
|
||||
"fabric-command-api-v2": "*",
|
||||
"minecraft": ">=1.16.2"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ import net.minecraftforge.client.ConfigScreenHandler;
|
|||
import net.minecraftforge.client.event.CustomizeGuiOverlayEvent;
|
||||
import net.minecraftforge.client.event.RecipesUpdatedEvent;
|
||||
import net.minecraftforge.client.event.RegisterKeyMappingsEvent;
|
||||
import net.minecraftforge.client.event.ScreenEvent;
|
||||
import net.minecraftforge.client.gui.overlay.ForgeGui;
|
||||
import net.minecraftforge.client.settings.KeyConflictContext;
|
||||
import net.minecraftforge.event.TagsUpdatedEvent;
|
||||
|
|
@ -87,11 +86,4 @@ public class ModernFixClientForge {
|
|||
public void onTags(TagsUpdatedEvent e) {
|
||||
commonMod.onTagsUpdated();
|
||||
}
|
||||
|
||||
@SubscribeEvent(priority = EventPriority.LOWEST)
|
||||
public void onScreen(ScreenEvent.Init.Pre event) {
|
||||
if(event.isCanceled())
|
||||
return;
|
||||
commonMod.onScreenOpening(event.getScreen());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user