diff options
| author | Linnea Gräf <nea@nea.moe> | 2025-11-16 16:03:35 +0100 |
|---|---|---|
| committer | Linnea Gräf <nea@nea.moe> | 2025-11-16 16:03:35 +0100 |
| commit | 44c1ee97c4fc4aa860c57966d938191b08d0994e (patch) | |
| tree | a36934f9406294f3174cdd6d433088a963a3e3a3 /src/main/java/moe | |
| parent | b132826a3149eae8fe2e3d4aa4d69d289557e2a4 (diff) | |
| download | Firmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.tar.gz Firmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.tar.bz2 Firmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.zip | |
snapshot: main menu
Diffstat (limited to 'src/main/java/moe')
5 files changed, 26 insertions, 11 deletions
diff --git a/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java index afd3104..836aee8 100644 --- a/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java @@ -3,10 +3,12 @@ package moe.nea.firmament.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.events.WorldKeyboardEvent; import moe.nea.firmament.keybindings.GenericInputAction; import moe.nea.firmament.keybindings.InputModifiers; import net.minecraft.client.Keyboard; +import net.minecraft.client.input.KeyInput; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,8 +17,8 @@ import org.spongepowered.asm.mixin.injection.At; public class KeyPressInWorldEventPatch { @WrapWithCondition(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V")) - public boolean onKeyBoardInWorld(InputUtil.Key key, long window, int _key, int scancode, int action, int modifiers) { - var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.key(_key, scancode), InputModifiers.of(modifiers))); + public boolean onKeyBoardInWorld(InputUtil.Key key, @Local(argsOnly = true) KeyInput keyInput) { + var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.of(keyInput), InputModifiers.of(keyInput))); return !event.getCancelled(); } } diff --git a/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java b/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java index d433f39..15fc5df 100644 --- a/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java +++ b/src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java @@ -2,6 +2,7 @@ package moe.nea.firmament.mixins; import moe.nea.firmament.keybindings.FirmamentKeyboardState; import net.minecraft.client.Keyboard; +import net.minecraft.client.input.KeyInput; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -10,7 +11,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @Mixin(Keyboard.class) public class MaintainKeyboardStatePatch { @Inject(method = "onKey", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/InactivityFpsLimiter;onInput()V")) - private void onKeyInput(long window, int key, int scancode, int action, int modifiers, CallbackInfo ci) { - FirmamentKeyboardState.INSTANCE.maintainState(key, scancode, action, modifiers); + private void onKeyInput(long window, int action, KeyInput input, CallbackInfo ci) { + FirmamentKeyboardState.INSTANCE.maintainState(input, action); } } diff --git a/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java b/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java index 8bd489c..fd2de97 100644 --- a/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java @@ -1,10 +1,12 @@ package moe.nea.firmament.mixins; import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; +import com.llamalad7.mixinextras.sugar.Local; import moe.nea.firmament.events.WorldKeyboardEvent; import moe.nea.firmament.keybindings.GenericInputAction; import moe.nea.firmament.keybindings.InputModifiers; import net.minecraft.client.Mouse; +import net.minecraft.client.input.MouseInput; import net.minecraft.client.util.InputUtil; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -12,8 +14,9 @@ import org.spongepowered.asm.mixin.injection.At; @Mixin(Mouse.class) public class MousePressInWorldEventPatch { @WrapWithCondition(method = "onMouseButton", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;onKeyPressed(Lnet/minecraft/client/util/InputUtil$Key;)V")) - public boolean onKeyBoardInWorld(InputUtil.Key key, long window, int button, int action, int mods) { - var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.mouse(button), InputModifiers.of(mods))); + public boolean onKeyBoardInWorld(InputUtil.Key key, @Local(argsOnly = true) MouseInput input) { // TODO: handle modified mouse click instead + var event = WorldKeyboardEvent.Companion.publish(new WorldKeyboardEvent(GenericInputAction.of(input), + InputModifiers.of(input))); return !event.getCancelled(); } } diff --git a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java index 334463b..3659066 100644 --- a/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java @@ -25,12 +25,12 @@ public class SaveCursorPositionPatch { SaveCursorPosition.saveCursorOriginal(x, y); } - @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + @Inject(method = "lockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getWindow()Lnet/minecraft/client/util/Window;", ordinal = 2)) public void onLockCursorAfter(CallbackInfo ci) { SaveCursorPosition.saveCursorMiddle(x, y); } - @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/util/Window;getHandle()J")) + @Inject(method = "unlockCursor", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;getWindow()Lnet/minecraft/client/util/Window;", ordinal = 2)) public void onUnlockCursor(CallbackInfo ci) { Pair<Double, Double> cursorPosition = SaveCursorPosition.loadCursor(this.x, this.y); if (cursorPosition == null) return; diff --git a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java index e268819..162d1dc 100644 --- a/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java +++ b/src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java @@ -6,9 +6,12 @@ import com.mojang.blaze3d.buffers.GpuBufferSlice; import moe.nea.firmament.events.WorldRenderLastEvent; import net.minecraft.client.render.*; import net.minecraft.client.render.fog.FogRenderer; +import net.minecraft.client.render.state.WorldRenderState; import net.minecraft.client.util.Handle; import net.minecraft.client.util.math.MatrixStack; +import net.minecraft.client.world.ClientWorld; import net.minecraft.util.profiler.Profiler; +import org.jetbrains.annotations.Nullable; import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -30,14 +33,20 @@ public abstract class WorldRenderLastEventPatch { @Shadow protected abstract void checkEmpty(MatrixStack matrices); + @Shadow + private @Nullable ClientWorld world; + + @Shadow + private int ticks; + @Inject(method = "method_62214", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V", shift = At.Shift.AFTER)) - public void onWorldRenderLast(GpuBufferSlice gpuBufferSlice, RenderTickCounter renderTickCounter, Camera camera, Profiler profiler, Matrix4f matrix4f, Handle handle, Handle handle2, boolean bl, Frustum frustum, Handle handle3, Handle handle4, CallbackInfo ci) { + public void onWorldRenderLast(GpuBufferSlice gpuBufferSlice, WorldRenderState worldRenderState, Profiler profiler, Matrix4f matrix4f, Handle handle, Handle handle2, boolean bl, Frustum frustum, Handle handle3, Handle handle4, CallbackInfo ci) { var imm = this.bufferBuilders.getEntityVertexConsumers(); var stack = new MatrixStack(); // TODO: pre-cancel this event if F1 is active var event = new WorldRenderLastEvent( - stack, renderTickCounter, - camera, + stack, ticks, + worldRenderState.cameraRenderState, imm ); WorldRenderLastEvent.Companion.publish(event); |
