aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java
blob: 10b4f619d6e08f715f310c4160f53bec82101a56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.dulkirfabric.mixin.render;

import com.dulkirfabric.config.DulkirConfig;
import net.minecraft.client.option.Perspective;
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.CallbackInfoReturnable;

@Mixin(Perspective.class)
public abstract class PerspectiveMixin {
    @Shadow public abstract boolean isFirstPerson();

    @Inject(method = "next", at = @At("HEAD"), cancellable = true)
    public void skipPerspective(CallbackInfoReturnable<Perspective> cir) {
        if (DulkirConfig.ConfigVars.getConfigOptions().getIgnoreReverseThirdPerson()) {
            if (this.isFirstPerson()) cir.setReturnValue(Perspective.THIRD_PERSON_BACK);
            else cir.setReturnValue(Perspective.FIRST_PERSON);
        }
    }
}