-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix runtime modified graphics settings potentially being saved
- Loading branch information
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
platforms/common/src/main/java/dynamic_fps/impl/mixin/OptionsMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package dynamic_fps.impl.mixin; | ||
|
||
import dynamic_fps.impl.DynamicFPSMod; | ||
import dynamic_fps.impl.config.option.GraphicsState; | ||
import dynamic_fps.impl.feature.state.OptionHolder; | ||
import net.minecraft.client.*; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
/** | ||
* Resets runtime modified graphics settings to the user-specified defaults during saving. | ||
* Prevents the game from saving the reduced or minimal preset to disk and loading it again. | ||
*/ | ||
@Mixin(Options.class) | ||
public abstract class OptionsMixin { | ||
@Inject(method = "save", at = @At("HEAD")) | ||
private void save0(CallbackInfo callbackInfo) { | ||
if (DynamicFPSMod.graphicsState() != GraphicsState.DEFAULT) { | ||
OptionHolder.applyOptions(Minecraft.getInstance().options, GraphicsState.DEFAULT); | ||
} | ||
} | ||
|
||
@Inject(method = "save", at = @At("RETURN")) | ||
private void save1(CallbackInfo callbackInfo) { | ||
if (DynamicFPSMod.graphicsState() != GraphicsState.DEFAULT) { | ||
OptionHolder.applyOptions(Minecraft.getInstance().options, DynamicFPSMod.graphicsState()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters