aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLinnea Gräf <nea@nea.moe>2025-11-16 16:03:35 +0100
committerLinnea Gräf <nea@nea.moe>2025-11-16 16:03:35 +0100
commit44c1ee97c4fc4aa860c57966d938191b08d0994e (patch)
treea36934f9406294f3174cdd6d433088a963a3e3a3 /src
parentb132826a3149eae8fe2e3d4aa4d69d289557e2a4 (diff)
downloadFirmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.tar.gz
Firmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.tar.bz2
Firmament-44c1ee97c4fc4aa860c57966d938191b08d0994e.zip
snapshot: main menu
Diffstat (limited to 'src')
-rw-r--r--src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java2
-rw-r--r--src/main/java/moe/nea/firmament/mixins/KeyPressInWorldEventPatch.java6
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MaintainKeyboardStatePatch.java5
-rw-r--r--src/main/java/moe/nea/firmament/mixins/MousePressInWorldEventPatch.java7
-rw-r--r--src/main/java/moe/nea/firmament/mixins/SaveCursorPositionPatch.java4
-rw-r--r--src/main/java/moe/nea/firmament/mixins/WorldRenderLastEventPatch.java15
-rw-r--r--src/main/kotlin/events/WorldRenderLastEvent.kt5
-rw-r--r--src/main/kotlin/keybindings/FirmamentKeyboardState.kt7
-rw-r--r--src/main/kotlin/keybindings/GenericInputButton.kt6
-rw-r--r--src/main/kotlin/util/render/RenderInWorldContext.kt9
-rw-r--r--src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java7
11 files changed, 47 insertions, 26 deletions
diff --git a/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java b/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java
index c3e8950..cf499f0 100644
--- a/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java
+++ b/src/compat/wildfireGender/java/moe/nea/firmament/mixins/compat/wildfiregender/PatchArmorTexturesInGenderMod.java
@@ -14,7 +14,7 @@ import org.spongepowered.asm.mixin.injection.At;
@Mixin(GenderArmorLayer.class)
@Pseudo
public class PatchArmorTexturesInGenderMod {
- @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V",
+ @ModifyExpressionValue(method = "render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/command/OrderedRenderCommandQueue;ILnet/minecraft/client/render/entity/state/BipedEntityRenderState;FF)V",
at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;get(Lnet/minecraft/component/ComponentType;)Ljava/lang/Object;"))
private Object replaceArmorMaterial(Object original, @Local ItemStack chestplate) {
var overrides = CustomGlobalArmorOverrides.overrideArmor(chestplate, EquipmentSlot.CHEST);
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);
diff --git a/src/main/kotlin/events/WorldRenderLastEvent.kt b/src/main/kotlin/events/WorldRenderLastEvent.kt
index 93d7e8c..e9d44fe 100644
--- a/src/main/kotlin/events/WorldRenderLastEvent.kt
+++ b/src/main/kotlin/events/WorldRenderLastEvent.kt
@@ -5,6 +5,7 @@ package moe.nea.firmament.events
import net.minecraft.client.render.Camera
import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.VertexConsumerProvider
+import net.minecraft.client.render.state.CameraRenderState
import net.minecraft.client.util.math.MatrixStack
/**
@@ -12,8 +13,8 @@ import net.minecraft.client.util.math.MatrixStack
*/
data class WorldRenderLastEvent(
val matrices: MatrixStack,
- val tickCounter: RenderTickCounter,
- val camera: Camera,
+ val tickCounter: Int,
+ val camera: CameraRenderState,
val vertexConsumers: VertexConsumerProvider.Immediate,
) : FirmamentEvent() {
companion object : FirmamentEventBus<WorldRenderLastEvent>()
diff --git a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
index 65288bc..dc20630 100644
--- a/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
+++ b/src/main/kotlin/keybindings/FirmamentKeyboardState.kt
@@ -2,6 +2,7 @@ package moe.nea.firmament.keybindings
import java.util.BitSet
import org.lwjgl.glfw.GLFW
+import net.minecraft.client.input.KeyInput
object FirmamentKeyboardState {
@@ -14,10 +15,10 @@ object FirmamentKeyboardState {
}
@Synchronized
- fun maintainState(key: Int, scancode: Int, action: Int, modifiers: Int) {
+ fun maintainState(keyInput: KeyInput, action: Int) {
when (action) {
- GLFW.GLFW_PRESS -> pressedScancodes.set(scancode)
- GLFW.GLFW_RELEASE -> pressedScancodes.clear(scancode)
+ GLFW.GLFW_PRESS -> pressedScancodes.set(keyInput.scancode)
+ GLFW.GLFW_RELEASE -> pressedScancodes.clear(keyInput.scancode)
}
}
}
diff --git a/src/main/kotlin/keybindings/GenericInputButton.kt b/src/main/kotlin/keybindings/GenericInputButton.kt
index a352ce0..3876573 100644
--- a/src/main/kotlin/keybindings/GenericInputButton.kt
+++ b/src/main/kotlin/keybindings/GenericInputButton.kt
@@ -15,7 +15,9 @@ import kotlinx.serialization.json.int
import kotlinx.serialization.json.put
import net.minecraft.client.MinecraftClient
import net.minecraft.client.gui.Click
+import net.minecraft.client.input.AbstractInput
import net.minecraft.client.input.KeyInput
+import net.minecraft.client.input.MouseInput
import net.minecraft.client.util.InputUtil
import net.minecraft.client.util.MacWindowUtil
import net.minecraft.text.Text
@@ -195,6 +197,8 @@ sealed interface GenericInputAction {
fun mouse(click: Click): GenericInputAction = mouse(click.button())
@JvmStatic
+ fun of(input: net.minecraft.client.input.MouseInput): GenericInputAction = mouse(input.button)
+ @JvmStatic
fun of(input: KeyInput): GenericInputAction = key(input.keycode, input.scancode)
@JvmStatic
@@ -276,7 +280,7 @@ data class InputModifiers(
fun of(modifiers: Int) = InputModifiers(modifiers)
@JvmStatic
- fun of(input: KeyInput) = InputModifiers(input.modifiers)
+ fun of(input: AbstractInput) = InputModifiers(input.modifiers())
fun none(): InputModifiers {
return InputModifiers(0)
diff --git a/src/main/kotlin/util/render/RenderInWorldContext.kt b/src/main/kotlin/util/render/RenderInWorldContext.kt
index b1ba9d0..116ae5d 100644
--- a/src/main/kotlin/util/render/RenderInWorldContext.kt
+++ b/src/main/kotlin/util/render/RenderInWorldContext.kt
@@ -12,6 +12,7 @@ import net.minecraft.client.render.RenderTickCounter
import net.minecraft.client.render.TexturedRenderLayers
import net.minecraft.client.render.VertexConsumer
import net.minecraft.client.render.VertexConsumerProvider
+import net.minecraft.client.render.state.CameraRenderState
import net.minecraft.client.texture.Sprite
import net.minecraft.client.util.math.MatrixStack
import net.minecraft.text.Text
@@ -26,8 +27,7 @@ import moe.nea.firmament.util.MC
@RenderContextDSL
class RenderInWorldContext private constructor(
val matrixStack: MatrixStack,
- private val camera: Camera,
- private val tickCounter: RenderTickCounter,
+ private val camera: CameraRenderState,
val vertexConsumers: VertexConsumerProvider.Immediate,
) {
fun block(blockPos: BlockPos, color: Int) {
@@ -105,7 +105,7 @@ class RenderInWorldContext private constructor(
val distanceToMoveTowardsCamera = if (actualCameraDistance < 10) 0.0 else -(actualCameraDistance - 10.0)
val vec = position.subtract(camera.pos).multiply(distanceToMoveTowardsCamera / actualCameraDistance)
matrixStack.translate(vec.x, vec.y, vec.z)
- matrixStack.multiply(camera.rotation)
+ matrixStack.multiply(camera.orientation)
matrixStack.scale(0.025F, -0.025F, 1F)
FacingThePlayerContext(this).run(block)
@@ -176,7 +176,7 @@ class RenderInWorldContext private constructor(
}
fun tracer(toWhere: Vec3d, color: Int, lineWidth: Float = 3f) {
- val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.rotation)
+ val cameraForward = Vector3f(0f, 0f, -1f).rotate(camera.orientation)
line(camera.pos.add(Vec3d(cameraForward)), toWhere, color = color, lineWidth = lineWidth)
}
@@ -301,7 +301,6 @@ class RenderInWorldContext private constructor(
val ctx = RenderInWorldContext(
event.matrices,
event.camera,
- event.tickCounter,
event.vertexConsumers
)
diff --git a/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java b/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java
index 5096c48..815e4bc 100644
--- a/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java
+++ b/src/texturePacks/java/moe/nea/firmament/mixins/custommodels/CustomSkullTexturePatch.java
@@ -4,6 +4,7 @@ package moe.nea.firmament.mixins.custommodels;
import moe.nea.firmament.features.texturepack.CustomSkyBlockTextures;
import net.minecraft.block.SkullBlock;
+import net.minecraft.block.entity.SkullBlockEntity;
import net.minecraft.client.render.RenderLayer;
import net.minecraft.client.render.block.entity.SkullBlockEntityRenderer;
import net.minecraft.component.type.ProfileComponent;
@@ -16,11 +17,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SkullBlockEntityRenderer.class)
public class CustomSkullTexturePatch {
@Inject(
- method = "getCutoutRenderLayer",
+ method = "renderSkull",
at = @At("HEAD"),
cancellable = true
)
- private static void onGetRenderLayer(SkullBlock.SkullType type, ProfileComponent profile, CallbackInfoReturnable<RenderLayer> cir) {
- CustomSkyBlockTextures.INSTANCE.modifySkullTexture(type, profile, cir);
+ private void onGetRenderLayer(SkullBlock.SkullType skullType, SkullBlockEntity blockEntity, CallbackInfoReturnable<RenderLayer> cir) {
+ CustomSkyBlockTextures.INSTANCE.modifySkullTexture(skullType, blockEntity.getOwner(), cir);
}
}