aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java')
-rw-r--r--src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java
new file mode 100644
index 0000000..3290aff
--- /dev/null
+++ b/src/main/java/me/djtheredstoner/perspectivemod/mixins/MixinEntityRenderer.java
@@ -0,0 +1,41 @@
+package me.djtheredstoner.perspectivemod.mixins;
+
+import me.djtheredstoner.perspectivemod.PerspectiveMod;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.renderer.EntityRenderer;
+import net.minecraft.entity.Entity;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Redirect;
+
+import static org.objectweb.asm.Opcodes.*;
+
+@Mixin(EntityRenderer.class)
+public class MixinEntityRenderer {
+
+ @Redirect(method = "updateCameraAndRender", at = @At(value = "FIELD", target = "Lnet/minecraft/client/Minecraft;inGameHasFocus:Z", opcode = GETFIELD))
+ public boolean updateCameraAndRender(Minecraft minecraft) {
+ return PerspectiveMod.overrideMouse();
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;rotationYaw:F", opcode = GETFIELD))
+ public float getRotationYaw(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraYaw : entity.rotationYaw;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;prevRotationYaw:F", opcode = GETFIELD))
+ public float getPrevRotationYaw(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraYaw : entity.prevRotationYaw;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;rotationPitch:F", opcode = GETFIELD))
+ public float getRotationPitch(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraPitch : entity.rotationPitch;
+ }
+
+ @Redirect(method = "orientCamera", at = @At(value = "FIELD", target = "Lnet/minecraft/entity/Entity;prevRotationPitch:F"))
+ public float getPrevRotationPitch(Entity entity) {
+ return PerspectiveMod.perspectiveToggled ? PerspectiveMod.cameraPitch : entity.prevRotationPitch;
+ }
+
+}