mirror of
https://github.com/darksaid98/Flashback.git
synced 2026-12-01 22:16:01 +00:00
Public Release
This commit is contained in:
1 parent
666398e480
commit
61bb497a22
126 files changed
+8435
-1240
No files matched your search
@@ -1,34 +1,46 @@
|
||||
package com.moulberry.flashback.mixin.visuals;
|
||||
|
||||
import com.moulberry.flashback.ReplayVisuals;
|
||||
import com.moulberry.flashback.state.EditorState;
|
||||
import com.moulberry.flashback.state.EditorStateManager;
|
||||
import com.moulberry.flashback.ext.OptionsExt;
|
||||
import net.minecraft.client.OptionInstance;
|
||||
import net.minecraft.client.Options;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
@Mixin(Options.class)
|
||||
public class MixinOptions {
|
||||
public class MixinOptions implements OptionsExt {
|
||||
|
||||
@Shadow
|
||||
@Final
|
||||
private OptionInstance<Integer> fov;
|
||||
@Unique
|
||||
private OptionInstance<Integer> cachedOptionInstance = null;
|
||||
private OptionInstance<Integer> cachedFovOptionInstance = null;
|
||||
|
||||
@Inject(method = "fov", at = @At("RETURN"), cancellable = true)
|
||||
public void fov(CallbackInfoReturnable<OptionInstance<Integer>> cir) {
|
||||
if (ReplayVisuals.overrideFov) {
|
||||
if (this.cachedOptionInstance == null || this.cachedOptionInstance.get() != Math.round(ReplayVisuals.overrideFovAmount)) {
|
||||
EditorState editorState = EditorStateManager.getCurrent();
|
||||
if (editorState != null && editorState.replayVisuals.overrideFov) {
|
||||
if (this.cachedFovOptionInstance == null || this.cachedFovOptionInstance.get() != Math.round(editorState.replayVisuals.overrideFovAmount)) {
|
||||
OptionInstance<Integer> delegate = cir.getReturnValue();
|
||||
this.cachedOptionInstance = new OptionInstance<>("options.fov", OptionInstance.noTooltip(), Options::genericValueLabel,
|
||||
delegate.values(), delegate.codec(), Math.round(ReplayVisuals.overrideFovAmount), value -> {
|
||||
ReplayVisuals.overrideFov = false;
|
||||
this.cachedFovOptionInstance = new OptionInstance<>("options.fov", OptionInstance.noTooltip(), Options::genericValueLabel,
|
||||
delegate.values(), delegate.codec(), Math.round(editorState.replayVisuals.overrideFovAmount), value -> {
|
||||
editorState.replayVisuals.overrideFov = false;
|
||||
delegate.set(value);
|
||||
});
|
||||
}
|
||||
|
||||
cir.setReturnValue(this.cachedOptionInstance);
|
||||
cir.setReturnValue(this.cachedFovOptionInstance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int flashback$getOriginalFov() {
|
||||
return this.fov.get();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user