2021-06-16 21:57:52 +02:00
|
|
|
package com.jozufozu.flywheel.mixin;
|
|
|
|
|
|
|
|
import javax.annotation.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;
|
|
|
|
|
|
|
|
import com.jozufozu.flywheel.backend.OptifineHandler;
|
|
|
|
|
|
|
|
import net.minecraft.client.Minecraft;
|
2021-09-15 08:45:29 +02:00
|
|
|
import net.minecraft.client.gui.screens.Screen;
|
|
|
|
import net.minecraft.client.gui.screens.VideoSettingsScreen;
|
2021-06-16 21:57:52 +02:00
|
|
|
|
|
|
|
@Mixin(Minecraft.class)
|
|
|
|
public class ShaderCloseMixin {
|
|
|
|
|
|
|
|
@Shadow
|
|
|
|
@Nullable
|
2021-07-15 20:51:57 +02:00
|
|
|
public Screen screen;
|
2021-06-16 21:57:52 +02:00
|
|
|
|
2021-07-15 20:51:57 +02:00
|
|
|
@Inject(at = @At("HEAD"), method = "setScreen")
|
2021-06-16 21:57:52 +02:00
|
|
|
private void whenScreenChanges(Screen screen, CallbackInfo info) {
|
2022-02-09 04:26:36 +01:00
|
|
|
if (OptifineHandler.isOptifineInstalled() && screen instanceof VideoSettingsScreen) {
|
2021-07-15 20:51:57 +02:00
|
|
|
Screen old = this.screen;
|
2021-06-16 21:57:52 +02:00
|
|
|
if (old != null && old.getClass()
|
2021-06-30 21:43:54 +02:00
|
|
|
.getName()
|
|
|
|
.startsWith(OptifineHandler.SHADER_PACKAGE)) {
|
2021-06-16 21:57:52 +02:00
|
|
|
OptifineHandler.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|