|
7 | 7 | */ |
8 | 8 | package net.wurstclient.mixin; |
9 | 9 |
|
10 | | -import org.joml.Matrix4f; |
11 | 10 | import org.spongepowered.asm.mixin.Mixin; |
12 | | -import org.spongepowered.asm.mixin.Unique; |
13 | 11 | import org.spongepowered.asm.mixin.injection.At; |
14 | 12 | import org.spongepowered.asm.mixin.injection.Inject; |
15 | 13 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
|
20 | 18 |
|
21 | 19 | import net.minecraft.client.render.Camera; |
22 | 20 | import net.minecraft.client.render.GameRenderer; |
23 | | -import net.minecraft.client.render.RenderTickCounter; |
24 | 21 | import net.minecraft.client.util.math.MatrixStack; |
25 | 22 | import net.minecraft.entity.Entity; |
26 | 23 | import net.minecraft.entity.LivingEntity; |
|
33 | 30 | @Mixin(GameRenderer.class) |
34 | 31 | public abstract class GameRendererMixin implements AutoCloseable |
35 | 32 | { |
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", |
44 | 34 | target = "Lnet/minecraft/client/render/GameRenderer;bobView(Lnet/minecraft/client/util/math/MatrixStack;F)V", |
45 | 35 | ordinal = 0), |
46 | 36 | 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) |
49 | 39 | { |
50 | 40 | CameraTransformViewBobbingEvent event = |
51 | 41 | new CameraTransformViewBobbingEvent(); |
52 | 42 | EventManager.fire(event); |
53 | 43 |
|
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); |
85 | 46 | } |
86 | 47 |
|
87 | 48 | @Inject(at = @At(value = "RETURN", ordinal = 1), |
|
0 commit comments