aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java')
-rw-r--r--src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
index 1f46f25..6fa950b 100644
--- a/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
+++ b/src/main/java/moe/nea/firmament/mixins/ScreenChangeEventPatch.java
@@ -1,11 +1,14 @@
/*
* SPDX-FileCopyrightText: 2023 Linnea Gräf <nea@nea.moe>
+ * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
package moe.nea.firmament.mixins;
+import com.llamalad7.mixinextras.sugar.Local;
+import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import moe.nea.firmament.events.ScreenChangeEvent;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
@@ -23,10 +26,12 @@ public abstract class ScreenChangeEventPatch {
public Screen currentScreen;
@Inject(method = "setScreen", at = @At("HEAD"), cancellable = true)
- public void onScreenChange(Screen screen, CallbackInfo ci) {
+ public void onScreenChange(Screen screen, CallbackInfo ci, @Local(argsOnly = true) LocalRef<Screen> screenLocalRef) {
var event = new ScreenChangeEvent(currentScreen, screen);
if (ScreenChangeEvent.Companion.publish(event).getCancelled()) {
ci.cancel();
+ } else if (event.getOverrideScreen() != null) {
+ screenLocalRef.set(event.getOverrideScreen());
}
}
}