-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a882efa
commit e8ff28c
Showing
2 changed files
with
28 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
src/main/java/com/emonadeo/autorun/mixin/LocalPlayerClientMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
package com.emonadeo.autorun.mixin; | ||
|
||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
||
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 { | ||
|
||
@Redirect(method = "aiStep()V", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/KeyMapping;isDown()Z")) | ||
public boolean isSprinting(KeyMapping keySprint) { | ||
// 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<Boolean> original) { | ||
Minecraft client = Minecraft.getInstance(); | ||
if (AutoRunMod.sprint && keySprint == client.options.keySprint) { | ||
if (AutoRunMod.sprint && instance == client.options.keySprint) { | ||
return true; | ||
} | ||
return keySprint.isDown(); | ||
return original.call(instance); | ||
} | ||
} |