Skip to content

Commit

Permalink
Optifine compat
Browse files Browse the repository at this point in the history
  • Loading branch information
dima-dencep committed Jan 26, 2024
1 parent ce4a1e9 commit b08f73b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 23 deletions.
@@ -1,3 +1,13 @@
/*
* Copyright 2023 dima_dencep.
*
* Licensed under the Open Software License, Version 3.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* https://github.com/dima-dencep/rrls/blob/HEAD/LICENSE
*/

package com.github.dimadencep.mods.rrls.config;

public enum DoubleLoad {
Expand Down
Expand Up @@ -14,7 +14,6 @@
import com.github.dimadencep.mods.rrls.Rrls;
import com.github.dimadencep.mods.rrls.utils.DummyDrawContext;
import com.github.dimadencep.mods.rrls.utils.OverlayHelper;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.DrawContext;
Expand All @@ -29,28 +28,10 @@

@Mixin(GameRenderer.class)
public class GameRendererMixin {

@Shadow
@Final
MinecraftClient client;

@ModifyExpressionValue(
method = "render",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/client/MinecraftClient;getOverlay()Lnet/minecraft/client/gui/screen/Overlay;",
ordinal = 0
)
)
public Overlay rrls$fixOverlayRendering(Overlay original, @Local(ordinal = 0) DrawContext drawContext) { // TODO @Local(name = "i", ordinal = 0, index = 7) int mouseX, @Local(name = "j", ordinal = 1, index = 8) int mouseY
if (!OverlayHelper.isRenderingState(original))
return original;

original.render(DummyDrawContext.INSTANCE, 0, 0, client.getLastFrameDuration());

return null;
}

@Inject(
method = "render",
at = @At(
Expand All @@ -62,8 +43,12 @@ public class GameRendererMixin {
try {
Overlay overlay = this.client.getOverlay();

if (ConfigExpectPlatform.miniRender() && OverlayHelper.isRenderingState(overlay))
overlay.rrls$miniRender(drawContext);
if (OverlayHelper.isRenderingState(overlay)) {
overlay.render(DummyDrawContext.INSTANCE, 0, 0, client.getLastFrameDuration());

if (ConfigExpectPlatform.miniRender())
overlay.rrls$miniRender(drawContext);
}

} catch (RuntimeException ex) {
Rrls.LOGGER.error(ex);
Expand Down
Expand Up @@ -17,14 +17,16 @@
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.Mouse;
import net.minecraft.client.gui.screen.Overlay;
import net.minecraft.client.render.GameRenderer;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;

@Mixin(value = {
GameRenderer.class,
Keyboard.class,
Mouse.class
})
public class KeyboardMouseMixin {
public class RendererKeyboardMouseMixin {
@WrapOperation(
method = "*",
at = @At(
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/resources/rrls-common.mixins.json
Expand Up @@ -8,7 +8,7 @@
"SplashOverlayMixin",
"TitleScreenMixin",
"compat.GameRendererMixin",
"compat.KeyboardMouseMixin",
"compat.RendererKeyboardMouseMixin",
"compat.OverlayMixin",
"compat.ServerResourcePackManagerMixin",
"workaround.DrawContentMixin"
Expand Down

0 comments on commit b08f73b

Please sign in to comment.