From b66f43911bfde35502fa7efc3fb08e25d1dd32f4 Mon Sep 17 00:00:00 2001 From: bconlon Date: Sun, 22 Dec 2024 12:45:09 -0800 Subject: [PATCH] fix: attempt profile crash solution --- .../com/aetherteam/cumulus/client/WorldDisplayHelper.java | 5 +++++ .../mixin/mixins/client/accessor/MinecraftAccessor.java | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/common/src/main/java/com/aetherteam/cumulus/client/WorldDisplayHelper.java b/common/src/main/java/com/aetherteam/cumulus/client/WorldDisplayHelper.java index 58ec3bf..83b0d38 100644 --- a/common/src/main/java/com/aetherteam/cumulus/client/WorldDisplayHelper.java +++ b/common/src/main/java/com/aetherteam/cumulus/client/WorldDisplayHelper.java @@ -4,6 +4,7 @@ import com.aetherteam.cumulus.CumulusConfig; import com.aetherteam.cumulus.mixin.mixins.client.accessor.MinecraftAccessor; import com.aetherteam.cumulus.mixin.mixins.common.accessor.MinecraftServerAccessor; +import com.mojang.blaze3d.systems.TimerQuery; import net.minecraft.client.CameraType; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.components.toasts.SystemToast; @@ -137,9 +138,13 @@ public static void stopLevel(@Nullable Screen screen) { * Sets up a menu through Cumulus and forces it as the current screen. */ public static void setMenu() { + MinecraftAccessor minecraftAccessor = (MinecraftAccessor) Minecraft.getInstance(); CumulusClient.MENU_HELPER.setShouldFade(false); Screen screen = CumulusClient.MENU_HELPER.applyMenu(CumulusClient.MENU_HELPER.getActiveMenu()); if (screen != null) { + if (minecraftAccessor.cumulus$getCurrentFrameProfile() != null && !minecraftAccessor.cumulus$getCurrentFrameProfile().isDone()) { + TimerQuery.getInstance().ifPresent((timer) -> minecraftAccessor.cumulus$setCurrentFrameProfile(timer.endProfile())); + } Minecraft.getInstance().forceSetScreen(screen); } } diff --git a/common/src/main/java/com/aetherteam/cumulus/mixin/mixins/client/accessor/MinecraftAccessor.java b/common/src/main/java/com/aetherteam/cumulus/mixin/mixins/client/accessor/MinecraftAccessor.java index fdff0a7..bf5ba4f 100644 --- a/common/src/main/java/com/aetherteam/cumulus/mixin/mixins/client/accessor/MinecraftAccessor.java +++ b/common/src/main/java/com/aetherteam/cumulus/mixin/mixins/client/accessor/MinecraftAccessor.java @@ -1,5 +1,6 @@ package com.aetherteam.cumulus.mixin.mixins.client.accessor; +import com.mojang.blaze3d.systems.TimerQuery; import net.minecraft.client.Minecraft; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -8,4 +9,10 @@ public interface MinecraftAccessor { @Accessor("isLocalServer") void cumulus$setIsLocalServer(boolean isLocalServer); + + @Accessor("currentFrameProfile") + TimerQuery.FrameProfile cumulus$getCurrentFrameProfile(); + + @Accessor("currentFrameProfile") + void cumulus$setCurrentFrameProfile(TimerQuery.FrameProfile currentFrameProfile); }