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