From f3f6da9f50edfbe9ed3be42fa16146210e60fbf3 Mon Sep 17 00:00:00 2001 From: inglettronald Date: Sat, 10 Jun 2023 21:38:38 -0500 Subject: yeah I'm not documenting this today --- .../dulkirfabric/mixin/io/HandledScreenMixin.java | 1 - .../com/dulkirfabric/mixin/render/CameraMixin.java | 9 ------- .../mixin/render/GameRendererMixin.java | 28 +++++++++++++++++++++- .../mixin/render/PerspectiveMixin.java | 22 +++++++++++++++++ .../com/dulkirfabric/mixin/render/ScreenMixin.java | 2 +- .../dulkirfabric/mixin/render/TooltipMixin.java | 8 ------- 6 files changed, 50 insertions(+), 20 deletions(-) delete mode 100644 src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java create mode 100644 src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java delete mode 100644 src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java (limited to 'src/main/java/com/dulkirfabric') diff --git a/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java index 430faa0..dbf8dbd 100644 --- a/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java @@ -5,7 +5,6 @@ import com.dulkirfabric.events.SlotRenderEvent; import net.minecraft.client.gui.DrawContext; import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.screen.slot.Slot; -import net.minecraft.screen.slot.SlotActionType; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java b/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java deleted file mode 100644 index 7ad4606..0000000 --- a/src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.dulkirfabric.mixin.render; - -import net.minecraft.client.render.Camera; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(Camera.class) -public class CameraMixin { - -} diff --git a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java index ab86cd9..e8f21bb 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java @@ -1,12 +1,38 @@ package com.dulkirfabric.mixin.render; +import com.dulkirfabric.config.DulkirConfig; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.screen.Screen; +import net.minecraft.client.gui.screen.ingame.HandledScreen; import net.minecraft.client.render.GameRenderer; 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.callback.CallbackInfo; @Mixin(GameRenderer.class) public class GameRendererMixin { - // TODO: THIS CODE IS NOT WORKING + private double normalScale = -1; + + @Inject(method = "render", at = @At(value = "HEAD")) + public void onRenderStart(float tickDelta, long startTime, boolean tick, CallbackInfo ci) { + if (!DulkirConfig.ConfigVars.getConfigOptions().getInvScaleBool()) return; + Screen screen = MinecraftClient.getInstance().currentScreen; + if (screen instanceof HandledScreen) { + normalScale = MinecraftClient.getInstance().getWindow().getScaleFactor(); + MinecraftClient.getInstance().getWindow().setScaleFactor(DulkirConfig.ConfigVars.getConfigOptions().getInventoryScale()); + } + } + + @Inject(method = "render", at = @At(value = "TAIL")) + public void onRenderEnd(float tickDelta, long startTime, boolean tick, CallbackInfo ci) { + if (!DulkirConfig.ConfigVars.getConfigOptions().getInvScaleBool()) return; + Screen screen = MinecraftClient.getInstance().currentScreen; + if (screen instanceof HandledScreen) { + MinecraftClient.getInstance().getWindow().setScaleFactor(normalScale); + } + } } \ No newline at end of file diff --git a/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java b/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java new file mode 100644 index 0000000..10b4f61 --- /dev/null +++ b/src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java @@ -0,0 +1,22 @@ +package com.dulkirfabric.mixin.render; + +import com.dulkirfabric.config.DulkirConfig; +import net.minecraft.client.option.Perspective; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(Perspective.class) +public abstract class PerspectiveMixin { + @Shadow public abstract boolean isFirstPerson(); + + @Inject(method = "next", at = @At("HEAD"), cancellable = true) + public void skipPerspective(CallbackInfoReturnable cir) { + if (DulkirConfig.ConfigVars.getConfigOptions().getIgnoreReverseThirdPerson()) { + if (this.isFirstPerson()) cir.setReturnValue(Perspective.THIRD_PERSON_BACK); + else cir.setReturnValue(Perspective.FIRST_PERSON); + } + } +} diff --git a/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java b/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java index 56ed0f9..3c890c7 100644 --- a/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java +++ b/src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java @@ -33,6 +33,6 @@ public abstract class ScreenMixin { @Inject(method = "resize", at = @At("HEAD")) private void beforeResizeScreen(MinecraftClient client, int width, int height, CallbackInfo ci) { - + //todo: impl } } \ No newline at end of file diff --git a/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java b/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java deleted file mode 100644 index b484885..0000000 --- a/src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.dulkirfabric.mixin.render; - -import net.minecraft.client.gui.tooltip.Tooltip; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(Tooltip.class) -public class TooltipMixin { -} -- cgit