1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package com.dulkirfabric.mixin.render;
import com.dulkirfabric.features.InventoryScale;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.render.GameRenderer;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(value = GameRenderer.class, priority = 1001)
public class GameRendererMixin {
@ModifyArg(method = "render", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V"),
index = 1)
public int fixMouseX(int mouseX) {
return (int) (mouseX / InventoryScale.INSTANCE.getScale());
}
@ModifyArg(method = "render", at = @At(value = "INVOKE",
target = "Lnet/minecraft/client/gui/screen/Screen;renderWithTooltip(Lnet/minecraft/client/gui/DrawContext;IIF)V"),
index = 2)
public int fixMouseY(int mouseY) {
return (int) (mouseY / InventoryScale.INSTANCE.getScale());
}
@Inject(method = "render", at = @At(value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
shift = At.Shift.BEFORE,
ordinal = 1))
public void onScreenRenderPre(float tickDelta, long startTime, boolean tick, CallbackInfo ci, @Local DrawContext drawContext) {
drawContext.getMatrices().push();
drawContext.getMatrices().scale(InventoryScale.INSTANCE.getScale(), InventoryScale.INSTANCE.getScale(), 1f);
}
@Inject(method = "render", at = @At(value = "FIELD",
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
shift = At.Shift.AFTER,
ordinal = 3)
)
public void onScreenRenderPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, @Local DrawContext drawContext) {
drawContext.getMatrices().pop();
}
}
|