diff options
author | nea <nea@nea.moe> | 2023-05-03 00:52:37 +0200 |
---|---|---|
committer | nea <nea@nea.moe> | 2023-05-03 00:52:49 +0200 |
commit | 3be33bb522f468b812bb59b7f2edc8d1ca352661 (patch) | |
tree | 1292a52cb661ab71584b1ae248204e18b869afe1 /src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java | |
parent | a8ab8f3d6326211f6e07694c64ebd8b6ba195988 (diff) | |
download | firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.gz firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.tar.bz2 firmament-3be33bb522f468b812bb59b7f2edc8d1ca352661.zip |
Modernize and 1.19.4ify
Diffstat (limited to 'src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java')
-rw-r--r-- | src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java new file mode 100644 index 0000000..17f49e1 --- /dev/null +++ b/src/main/java/moe/nea/notenoughupdates/mixins/MixinMinecraft.java @@ -0,0 +1,26 @@ +package moe.nea.notenoughupdates.mixins; + +import moe.nea.notenoughupdates.events.ScreenOpenEvent; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; +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; + +@Mixin(MinecraftClient.class) +public abstract class MixinMinecraft { + @Shadow + @Nullable + public Screen currentScreen; + + @Inject(method = "setScreen", at = @At("HEAD"), cancellable = true) + public void onScreenChange(Screen screen, CallbackInfo ci) { + var event = new ScreenOpenEvent(currentScreen, screen); + if (ScreenOpenEvent.Companion.publish(event).getCancelled()) { + ci.cancel(); + } + } +} |