aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoringlettronald <inglettronald@gmail.com>2023-06-29 07:22:00 -0500
committeringlettronald <inglettronald@gmail.com>2023-06-29 07:22:00 -0500
commit1fc9c0f7fe8a998e4cf04c8b498abc643533d6e7 (patch)
treeebb20a97c5070c1523765d2a8a4832229f46dfc0 /src
parent2c022844e58c4a62b09a287f6e71cfb8a3ab1922 (diff)
downloadDulkirMod-Fabric-1fc9c0f7fe8a998e4cf04c8b498abc643533d6e7.tar.gz
DulkirMod-Fabric-1fc9c0f7fe8a998e4cf04c8b498abc643533d6e7.tar.bz2
DulkirMod-Fabric-1fc9c0f7fe8a998e4cf04c8b498abc643533d6e7.zip
added some funky features, might remove later
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java5
-rw-r--r--src/main/kotlin/com/dulkirfabric/features/InventoryScale.kt32
2 files changed, 34 insertions, 3 deletions
diff --git a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
index 17f527b..78b4dbd 100644
--- a/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
+++ b/src/main/java/com/dulkirfabric/mixin/render/GameRendererMixin.java
@@ -15,7 +15,7 @@ import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
-@Mixin(GameRenderer.class)
+@Mixin(value = GameRenderer.class, priority = 1001)
public class GameRendererMixin {
@ModifyArg(method = "render", at = @At(value = "INVOKE",
@@ -49,7 +49,8 @@ public class GameRendererMixin {
opcode = Opcodes.GETFIELD,
target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;",
shift = At.Shift.AFTER,
- ordinal = 3), locals = LocalCapture.CAPTURE_FAILHARD)
+ ordinal = 3), locals = LocalCapture.CAPTURE_FAILHARD
+ )
public void onScreenRenderPost(float tickDelta, long startTime, boolean tick, CallbackInfo ci, int i, int j,
Window window, Matrix4f matrix4f, MatrixStack matrixStack, DrawContext drawContext) {
drawContext.getMatrices().pop();
diff --git a/src/main/kotlin/com/dulkirfabric/features/InventoryScale.kt b/src/main/kotlin/com/dulkirfabric/features/InventoryScale.kt
index 0d2fc4a..eccfb2c 100644
--- a/src/main/kotlin/com/dulkirfabric/features/InventoryScale.kt
+++ b/src/main/kotlin/com/dulkirfabric/features/InventoryScale.kt
@@ -2,16 +2,46 @@ package com.dulkirfabric.features
import com.dulkirfabric.DulkirModFabric.mc
import com.dulkirfabric.config.DulkirConfig
+import com.dulkirfabric.events.ClientTickEvent
+import com.dulkirfabric.events.MouseScrollEvent
+import meteordevelopment.orbit.EventHandler
+import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.screen.ingame.HandledScreen
+import net.minecraft.client.util.InputUtil
+import org.lwjgl.glfw.GLFW
object InventoryScale {
+ private var scaleBuffer = DulkirConfig.configOptions.inventoryScale
+ private var prevTickScale = DulkirConfig.configOptions.inventoryScale
+ private var tickScale = DulkirConfig.configOptions.inventoryScale
+
+
/**
* Called every render frame, so don't put anything expensive in here.
*/
fun getScale(): Float {
- if (DulkirConfig.configOptions.invScaleBool && mc.currentScreen is HandledScreen<*>)
+ if (DulkirConfig.configOptions.invScaleBool && mc.currentScreen is HandledScreen<*>) {
+ val partialTicks = MinecraftClient.getInstance().tickDelta
+ DulkirConfig.configOptions.inventoryScale = prevTickScale + ((tickScale - prevTickScale) * partialTicks)
return DulkirConfig.configOptions.inventoryScale
+ }
return 1f
}
+
+ @EventHandler
+ fun onScroll(event: MouseScrollEvent) {
+ // TODO: ignore input in config screen
+ if (event.verticalScrollAmount == 0.0) return
+ val handle = MinecraftClient.getInstance().window.handle
+ if (InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT_CONTROL) && InputUtil.isKeyPressed(handle, GLFW.GLFW_KEY_LEFT_ALT))
+ scaleBuffer += (.05 * event.verticalScrollAmount).toFloat()
+ }
+
+ @EventHandler
+ fun onTick(event: ClientTickEvent) {
+ // flushes the buffer to a scroll amount this tick, will be interpolated in calculatePos
+ prevTickScale = tickScale
+ tickScale = scaleBuffer
+ }
} \ No newline at end of file