diff --git a/src/main/java/com/emonadeo/autorun/mixin/InputClientMixin.java b/src/main/java/com/emonadeo/autorun/mixin/InputClientMixin.java index 49568cc..232c451 100644 --- a/src/main/java/com/emonadeo/autorun/mixin/InputClientMixin.java +++ b/src/main/java/com/emonadeo/autorun/mixin/InputClientMixin.java @@ -1,10 +1,10 @@ package com.emonadeo.autorun.mixin; -import com.llamalad7.mixinextras.injector.ModifyReturnValue; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import com.emonadeo.autorun.AutoRunMod; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; @@ -13,11 +13,7 @@ @Environment(EnvType.CLIENT) @Mixin(Input.class) public class InputClientMixin { - // In the standard mixin world, - // a redirect implies that you want to stop all - // other mods from touching anything relating to this - // and crash the game if they try. - // For mod compatibility, it is better to find a more specific injector + @ModifyReturnValue(method = "forward", at = @At("TAIL")) public boolean forward(boolean original) { return original || AutoRunMod.forward; diff --git a/src/main/java/com/emonadeo/autorun/mixin/LocalPlayerClientMixin.java b/src/main/java/com/emonadeo/autorun/mixin/LocalPlayerClientMixin.java index e7b4440..4d51c94 100644 --- a/src/main/java/com/emonadeo/autorun/mixin/LocalPlayerClientMixin.java +++ b/src/main/java/com/emonadeo/autorun/mixin/LocalPlayerClientMixin.java @@ -1,23 +1,24 @@ package com.emonadeo.autorun.mixin; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + import com.emonadeo.autorun.AutoRunMod; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; + import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.KeyMapping; import net.minecraft.client.Minecraft; import net.minecraft.client.player.LocalPlayer; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; @Environment(EnvType.CLIENT) @Mixin(LocalPlayer.class) public class LocalPlayerClientMixin { - // effectively a conditional redirect, - // only overriding other mods if the condition is met + @WrapOperation(method = "aiStep()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/KeyMapping;isDown()Z")) - public boolean isSprinting(KeyMapping instance, Operation original) { + public boolean wrapSprint(KeyMapping instance, Operation original) { Minecraft client = Minecraft.getInstance(); if (AutoRunMod.sprint && instance == client.options.keySprint) { return true;