aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/dulkirfabric
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-10 21:38:38 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-10 21:38:38 -0500
commitf3f6da9f50edfbe9ed3be42fa16146210e60fbf3 (patch)
tree96c54aa7de1bd2d79d062ad0f787e46c88034a83 /src/main/java/com/dulkirfabric
parent22508bb83e8d5846a7a68dd5346e8a2013e1c710 (diff)
downloadDulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.tar.gz
DulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.tar.bz2
DulkirMod-Fabric-f3f6da9f50edfbe9ed3be42fa16146210e60fbf3.zip
yeah I'm not documenting this today
Diffstat (limited to 'src/main/java/com/dulkirfabric')
-rw-r--r--src/main/java/com/dulkirfabric/mixin/io/HandledScreenMixin.java1
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/CameraMixin.java9
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java28
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/PerspectiveMixin.java22
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/ScreenMixin.java2
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/TooltipMixin.java8
6 files changed, 50 insertions, 20 deletions
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<Perspective> 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 {
-}