禁用瞄准时跑步

This commit is contained in:
17146 2025-04-22 23:26:55 +08:00 committed by Light_Quanta
parent 77fa71a9ee
commit 625283ac73
No known key found for this signature in database
GPG key ID: 11A39A1B8C890959

View file

@ -1,9 +1,14 @@
package com.atsuishio.superbwarfare.mixins;
import com.atsuishio.superbwarfare.entity.ICustomKnockback;
import com.atsuishio.superbwarfare.event.ClientEventHandler;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.LivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(LivingEntity.class)
public class LivingEntityMixin implements ICustomKnockback {
@ -25,4 +30,13 @@ public class LivingEntityMixin implements ICustomKnockback {
public double superbWarfare$getKnockbackStrength() {
return this.superbwarfare$knockbackStrength;
}
@Inject(method = "setSprinting(Z)V", at = @At("HEAD"), cancellable = true)
public void setSprinting(boolean pSprinting, CallbackInfo ci) {
if (((LivingEntity) (Object) this) instanceof LocalPlayer) {
if (pSprinting && ClientEventHandler.zoom) {
ci.cancel();
}
}
}
}