Skip to content

Commit a2b27e0

Browse files
Merge branch 'v7.51' into v7.51-1.21.9
2 parents 483cccd + 7f2a4ac commit a2b27e0

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

src/main/java/net/wurstclient/mixin/GameRendererMixin.java

Lines changed: 5 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@
77
*/
88
package net.wurstclient.mixin;
99

10-
import org.joml.Matrix4f;
1110
import org.spongepowered.asm.mixin.Mixin;
12-
import org.spongepowered.asm.mixin.Unique;
1311
import org.spongepowered.asm.mixin.injection.At;
1412
import org.spongepowered.asm.mixin.injection.Inject;
1513
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@@ -20,7 +18,6 @@
2018

2119
import net.minecraft.client.render.Camera;
2220
import net.minecraft.client.render.GameRenderer;
23-
import net.minecraft.client.render.RenderTickCounter;
2421
import net.minecraft.client.util.math.MatrixStack;
2522
import net.minecraft.entity.Entity;
2623
import net.minecraft.entity.LivingEntity;
@@ -33,55 +30,19 @@
3330
@Mixin(GameRenderer.class)
3431
public abstract class GameRendererMixin implements AutoCloseable
3532
{
36-
@Unique
37-
private boolean cancelNextBobView;
38-
39-
/**
40-
* Fires the CameraTransformViewBobbingEvent event and records whether the
41-
* next view-bobbing call should be cancelled.
42-
*/
43-
@Inject(at = @At(value = "INVOKE",
33+
@WrapOperation(at = @At(value = "INVOKE",
4434
target = "Lnet/minecraft/client/render/GameRenderer;bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V",
4535
ordinal = 0),
4636
method = "renderWorld(Lnet/minecraft/client/render/RenderTickCounter;)V")
47-
private void onRenderWorldViewBobbing(RenderTickCounter tickCounter,
48-
CallbackInfo ci)
37+
private void onBobView(GameRenderer instance, MatrixStack matrices,
38+
float tickDelta, Operation<Void> original)
4939
{
5040
CameraTransformViewBobbingEvent event =
5141
new CameraTransformViewBobbingEvent();
5242
EventManager.fire(event);
5343

54-
if(event.isCancelled())
55-
cancelNextBobView = true;
56-
}
57-
58-
/**
59-
* Cancels the view-bobbing call if requested by the last
60-
* CameraTransformViewBobbingEvent.
61-
*/
62-
@Inject(at = @At("HEAD"),
63-
method = "bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V",
64-
cancellable = true)
65-
private void onBobView(MatrixStack matrices, float tickDelta,
66-
CallbackInfo ci)
67-
{
68-
if(!cancelNextBobView)
69-
return;
70-
71-
ci.cancel();
72-
cancelNextBobView = false;
73-
}
74-
75-
/**
76-
* This mixin is injected into a random method call later in the
77-
* renderWorld() method to ensure that cancelNextBobView is always reset
78-
* after the view-bobbing call.
79-
*/
80-
@Inject(at = @At("HEAD"), method = "renderHand(FZLorg/joml/Matrix4f;)V")
81-
private void onRenderHand(float tickDelta, boolean bl, Matrix4f matrix4f,
82-
CallbackInfo ci)
83-
{
84-
cancelNextBobView = false;
44+
if(!event.isCancelled())
45+
original.call(instance, matrices, tickDelta);
8546
}
8647

8748
@Inject(at = @At(value = "RETURN", ordinal = 1),

0 commit comments

Comments
 (0)