diff --git a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/MixinMouse.java b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/MixinMouse.java index 893105fd38..adf0dac2ac 100644 --- a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/MixinMouse.java +++ b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/MixinMouse.java @@ -5,6 +5,8 @@ package dev.lyzev.schizoid.injection.mixins.minecraft.client; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.lyzev.api.events.EventIsCursorLocked; import dev.lyzev.api.events.EventMouseClick; import dev.lyzev.api.events.EventMouseScroll; @@ -15,7 +17,6 @@ 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; /** @@ -49,9 +50,9 @@ private void onMouseButton(long window, int button, int action, int mods, Callba * @param instance The Mouse instance. * @return The return value of the event. */ - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;isCursorLocked()Z")) - private boolean onTick(Mouse instance) { - EventIsCursorLocked event = new EventIsCursorLocked(instance.isCursorLocked()); + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Mouse;isCursorLocked()Z")) + private boolean onTick(Mouse instance, Operation original) { + EventIsCursorLocked event = new EventIsCursorLocked(original.call(instance)); event.fire(); return event.isCursorLocked(); } diff --git a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/input/MixinKeyboardInput.java b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/input/MixinKeyboardInput.java index 86ef5505ff..c59418289a 100644 --- a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/input/MixinKeyboardInput.java +++ b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/input/MixinKeyboardInput.java @@ -5,12 +5,13 @@ package dev.lyzev.schizoid.injection.mixins.minecraft.client.input; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.lyzev.api.events.EventIsMovementKeyPressed; import net.minecraft.client.input.KeyboardInput; import net.minecraft.client.option.KeyBinding; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; /** * This class provides a mixin for the KeyboardInput class in the Minecraft client input package. @@ -27,8 +28,8 @@ public class MixinKeyboardInput { * @param instance The key binding that was pressed. * @return The return value of the event. */ - @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z")) - private boolean onTick(KeyBinding instance) { + @WrapOperation(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z")) + private boolean onTick(KeyBinding instance, Operation original) { EventIsMovementKeyPressed event = new EventIsMovementKeyPressed(instance); event.fire(); return event.isPressed(); diff --git a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/network/MixinClientPlayerEntity.java b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/network/MixinClientPlayerEntity.java index 21d80ff0da..2dea90b53c 100644 --- a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/network/MixinClientPlayerEntity.java +++ b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/network/MixinClientPlayerEntity.java @@ -5,6 +5,8 @@ package dev.lyzev.schizoid.injection.mixins.minecraft.client.network; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import dev.lyzev.api.events.EventClientPlayerEntityTick; import dev.lyzev.api.events.EventIsMovementKeyPressed; import net.minecraft.client.network.ClientPlayerEntity; @@ -12,7 +14,6 @@ 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.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; /** @@ -41,8 +42,8 @@ private void onTick(CallbackInfo ci) { * @param instance The key binding that is checked. * @return The return value of the event. */ - @Redirect(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z")) - private boolean onTickMovement(KeyBinding instance) { + @WrapOperation(method = "tickMovement", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/option/KeyBinding;isPressed()Z")) + private boolean onTickMovement(KeyBinding instance, Operation original) { EventIsMovementKeyPressed event = new EventIsMovementKeyPressed(instance); event.fire(); return event.isPressed(); diff --git a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/render/entity/MixinLivingEntityRenderer.java b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/render/entity/MixinLivingEntityRenderer.java index fe7922b569..0026c73dce 100644 --- a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/render/entity/MixinLivingEntityRenderer.java +++ b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/render/entity/MixinLivingEntityRenderer.java @@ -5,6 +5,7 @@ package dev.lyzev.schizoid.injection.mixins.minecraft.client.render.entity; +import com.llamalad7.mixinextras.injector.v2.WrapWithCondition; import dev.lyzev.api.events.EventRenderModel; import net.minecraft.client.render.VertexConsumer; import net.minecraft.client.render.entity.LivingEntityRenderer; @@ -12,7 +13,6 @@ import net.minecraft.client.util.math.MatrixStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; /** * This class provides a mixin for the LivingEntityRenderer class in the Minecraft client render entity package. @@ -26,20 +26,22 @@ public class MixinLivingEntityRenderer { * It creates and fires an EventRenderModel event when the model is rendered. * The parameters of the render method are then replaced by the parameters of the event. * - * @param instance The instance of the EntityModel class. - * @param matrixStack The matrix stack used for transformations. + * @param instance The instance of the EntityModel class. + * @param matrixStack The matrix stack used for transformations. * @param vertexConsumer The vertex consumer used for rendering. - * @param light The light level for the render. - * @param overlay The overlay level for the render. - * @param red The red color component for the render. - * @param green The green color component for the render. - * @param blue The blue color component for the render. - * @param alpha The alpha component for the render. + * @param light The light level for the render. + * @param overlay The overlay level for the render. + * @param red The red color component for the render. + * @param green The green color component for the render. + * @param blue The blue color component for the render. + * @param alpha The alpha component for the render. + * @return */ - @Redirect(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) - private void onRenderModel(EntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { + @WrapWithCondition(method = "render(Lnet/minecraft/entity/LivingEntity;FFLnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumerProvider;I)V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/entity/model/EntityModel;render(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/render/VertexConsumer;IIFFFF)V")) + private boolean onRenderModel(EntityModel instance, MatrixStack matrixStack, VertexConsumer vertexConsumer, int light, int overlay, float red, float green, float blue, float alpha) { EventRenderModel event = new EventRenderModel(instance, matrixStack, vertexConsumer, light, overlay, red, green, blue, alpha); event.fire(); instance.render(event.getMatrixStack(), event.getVertexConsumer(), event.getLight(), event.getOverlay(), event.getRed(), event.getGreen(), event.getBlue(), event.getAlpha()); + return false; } } diff --git a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/util/MixinWindow.java b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/util/MixinWindow.java index 3af9ce0b5f..b04eff6384 100644 --- a/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/util/MixinWindow.java +++ b/src/main/java/dev/lyzev/schizoid/injection/mixins/minecraft/client/util/MixinWindow.java @@ -7,13 +7,7 @@ import dev.lyzev.api.events.EventGlfwInit; import dev.lyzev.api.events.EventSwapBuffers; -import net.minecraft.client.WindowEventHandler; -import net.minecraft.client.WindowSettings; -import net.minecraft.client.util.MonitorTracker; import net.minecraft.client.util.Window; -import org.lwjgl.glfw.GLFW; -import org.lwjgl.opengl.GL13; -import org.lwjgl.opengl.GL44; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,8 +15,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static org.lwjgl.glfw.GLFW.GLFW_SAMPLES; - /** * This class provides a mixin for the Window class in the Minecraft client util package. * It modifies the behavior of the setPhase method of the Window class.