Skip to content

Commit

Permalink
Rename Mixin Function & Remove Comments
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Pilz <[email protected]>
  • Loading branch information
emonadeo committed Nov 10, 2024
1 parent 79b4506 commit c02ea6c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Boolean> original) {
public boolean wrapSprint(KeyMapping instance, Operation<Boolean> original) {
Minecraft client = Minecraft.getInstance();
if (AutoRunMod.sprint && instance == client.options.keySprint) {
return true;
Expand Down

0 comments on commit c02ea6c

Please sign in to comment.