Skip to content

Commit

Permalink
Update GameRendererMixin.java
Browse files Browse the repository at this point in the history
  • Loading branch information
AV306 authored Dec 25, 2023
1 parent 80c1e1a commit 9a19bdf
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/main/java/me/av306/xenon/mixin/GameRendererMixin.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
package me.av306.xenon.mixin;

import me.av306.xenon.Xenon;

import me.av306.xenon.event.EventFields;
import me.av306.xenon.event.GameRenderEvents;
import me.av306.xenon.event.GetFovEvent;

import net.minecraft.client.render.Camera;
import net.minecraft.client.render.GameRenderer;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.resource.ResourceManager;
import net.minecraft.resource.SynchronousResourceReloader;
import net.minecraft.util.ActionResult;

import org.objectweb.asm.Opcodes;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
Expand All @@ -23,18 +25,33 @@
@Mixin( GameRenderer.class )
public abstract class GameRendererMixin implements AutoCloseable, SynchronousResourceReloader
{
@Shadow public abstract void reset();
@Shadow
public abstract void reset();

// FIXME: replace with mixinextras ModifyReturnValue
@Inject(
at = @At( value = "RETURN", ordinal = 1 ),
method = "getFov(Lnet/minecraft/client/render/Camera;FZ)D",
cancellable = true
)

/*
@ModifyReturnValue(
at = @At( value = "RETURN", ordinal = 1 ),
method = "getFov(Lnet/minecraft/client/render/Camera;FZ)D"
)
*/
private void onGetFov( Camera camera, float tickDelta, boolean changingFov, CallbackInfoReturnable<Double> cir )
{
// Call event
GetFovEvent.EVENT.invoker().interact( camera, tickDelta, changingFov );
if ( EventFields.shouldOverrideFov ) cir.setReturnValue( EventFields.FOV_OVERRIDE / EventFields.FOV_ZOOM_LEVEL );
else cir.setReturnValue( (cir.getReturnValue() + EventFields.FOV_MODIFIER) / EventFields.FOV_ZOOM_LEVEL );

//if ( EventFields.shouldOverrideFov ) cir.setReturnValue( EventFields.FOV_OVERRIDE / EventFields.FOV_ZOOM_LEVEL );
//else cir.setReturnValue( (cir.getReturnValue() + EventFields.FOV_MODIFIER) / EventFields.FOV_ZOOM_LEVEL );

// I have never used the other two things I added (modifier and override)
// so out they go
cir.setReturnValue( cir.getReturnValue() / GetFovEvent.EventData.FOV_ZOOM_LEVEL );

//Xenon.INSTANCE.sendInfoMessage( String.valueOf( cir.getReturnValue() ) );
}
Expand Down

0 comments on commit 9a19bdf

Please sign in to comment.