Guard client config reads until config is loaded
This commit is contained in:
1 parent
681c6ed99b
commit
54593167d6
5 files changed
+18
No files matched your search
@@ -24,6 +24,10 @@ public final class ClientConfig {
|
||||
private ClientConfig() {
|
||||
}
|
||||
|
||||
public static boolean isLoaded() {
|
||||
return SPEC.isLoaded();
|
||||
}
|
||||
|
||||
public static OutputMode perfOutputMode() {
|
||||
return PERF_OUTPUT_MODE.get();
|
||||
}
|
||||
|
||||
@@ -150,6 +150,9 @@ public final class ClientSetup {
|
||||
}
|
||||
|
||||
private static void displayPerfReport(Minecraft minecraft, PerfReportData report) {
|
||||
if (!ClientConfig.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
switch (ClientConfig.perfOutputMode()) {
|
||||
case SCREEN -> minecraft.setScreen(new PerfReportScreen(report, false));
|
||||
case CHAT -> sendPerfReportToChat(minecraft, report);
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.moepus.serverwarashi.api.client.map.MapOverlayApi;
|
||||
import com.moepus.serverwarashi.api.client.map.MapOverlayControls;
|
||||
import com.moepus.serverwarashi.client.map.MapContextMenuService;
|
||||
import com.moepus.serverwarashi.client.map.MapOverlayRenderer;
|
||||
import com.moepus.serverwarashi.client.config.ClientConfig;
|
||||
import com.moepus.serverwarashi.client.network.PerfMapSubscriptionClient;
|
||||
import com.moepus.serverwarashi.client.state.ClientPerfMapState;
|
||||
import com.moepus.serverwarashi.client.state.ClientPerfStateCoordinator;
|
||||
@@ -28,6 +29,9 @@ public final class MapOverlayClientEvents {
|
||||
@SubscribeEvent
|
||||
public static void onClientTick(ClientTickEvent.Post event) {
|
||||
Minecraft minecraft = Minecraft.getInstance();
|
||||
if (!ClientConfig.isLoaded()) {
|
||||
return;
|
||||
}
|
||||
PerfMapSubscriptionClient.refreshWorldOverlayEnabled();
|
||||
if (minecraft.level != null) {
|
||||
ClientWeakChunkState.tick();
|
||||
|
||||
@@ -22,6 +22,9 @@ public final class PerfMapSubscriptionClient {
|
||||
}
|
||||
|
||||
public static boolean refreshWorldOverlayEnabled() {
|
||||
if (!ClientConfig.isLoaded()) {
|
||||
return false;
|
||||
}
|
||||
return STATE.setWorldOverlayEnabled(ClientConfig.worldOverlayEnabled());
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ public final class WorldPerfOverlayRenderer {
|
||||
}
|
||||
|
||||
public static void render(RenderLevelStageEvent event) {
|
||||
if (!ClientConfig.isLoaded()) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (!ClientConfig.worldOverlayEnabled()) {
|
||||
close();
|
||||
return;
|
||||
|
||||
Reference in new issue
Block a user