diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/com/dulkirfabric/mixin/render/DrawContextMixin.java | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/render/DrawContextMixin.java b/src/main/java/com/dulkirfabric/mixin/render/DrawContextMixin.java index 1bef0f5..79a71b2 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/DrawContextMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/DrawContextMixin.java @@ -1,12 +1,17 @@ package com.dulkirfabric.mixin.render; +import com.dulkirfabric.config.DulkirConfig; import com.dulkirfabric.events.TooltipRenderChangeEvent; +import com.dulkirfabric.features.InventoryScale; import com.dulkirfabric.features.TooltipImpl; import com.dulkirfabric.util.ItemChangeHandler; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.client.MinecraftClient; import net.minecraft.client.font.TextRenderer; import net.minecraft.client.gui.DrawContext; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.gui.tooltip.TooltipComponent; import net.minecraft.client.gui.tooltip.TooltipPositioner; import net.minecraft.client.util.math.MatrixStack; @@ -23,18 +28,27 @@ import java.util.List; @Mixin(DrawContext.class) public class DrawContextMixin { @Shadow @Final private MatrixStack matrices; - List<TooltipComponent> prevComponents; @WrapOperation(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At(target = "Lnet/minecraft/client/gui/tooltip/TooltipPositioner;getPosition(IIIIII)Lorg/joml/Vector2ic;", value = "INVOKE")) public Vector2ic drawTooltip(TooltipPositioner positionerInstance, int sw, int sh, int mx, int my, int tw, int th, Operation<Vector2ic> operation) { - Vector2ic v = operation.call(positionerInstance, sw, sh, mx, my, tw, th); - return TooltipImpl.INSTANCE.calculatePos(v); + Screen screen = MinecraftClient.getInstance().currentScreen; + if (!(screen instanceof HandledScreen)) { + return operation.call(positionerInstance, sw, sh, mx, my, tw, th); + } + float scale = InventoryScale.INSTANCE.getScale(); + float tooltipScale = DulkirConfig.ConfigVars.getConfigOptions().getTooltipScale(); + Vector2ic v = operation.call(positionerInstance, (int) (sw / scale), (int) (sh / scale), + mx , my, (int) (tw * tooltipScale), (int) (th * tooltipScale)); + return TooltipImpl.INSTANCE.calculatePos(v, (int) (tw * tooltipScale), + (int) (th * tooltipScale), (int) (sw / scale), (int) (sh / scale)); } @Inject(method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V", at = @At(target = "Lnet/minecraft/client/util/math/MatrixStack;push()V", value = "INVOKE")) public void onPush(TextRenderer textRenderer, List<TooltipComponent> components, int x, int y, TooltipPositioner positioner, CallbackInfo ci) { - TooltipImpl.INSTANCE.applyScale(matrices); + if (MinecraftClient.getInstance().currentScreen instanceof HandledScreen) { + TooltipImpl.INSTANCE.applyScale(matrices); + } } } |