diff --git a/src/main/java/com/mmodding/mmodding_lib/library/client/utils/AnimationUtils.java b/src/main/java/com/mmodding/mmodding_lib/library/client/utils/AnimationUtils.java new file mode 100644 index 0000000..ae6e3e4 --- /dev/null +++ b/src/main/java/com/mmodding/mmodding_lib/library/client/utils/AnimationUtils.java @@ -0,0 +1,16 @@ +package com.mmodding.mmodding_lib.library.client.utils; + +import net.minecraft.entity.LivingEntity; +import net.minecraft.util.math.MathHelper; +import net.minecraft.util.math.Vec3d; +import org.quiltmc.loader.api.minecraft.ClientOnly; + +@ClientOnly +public class AnimationUtils { + + public boolean isMoving(LivingEntity livingEntity, float limbSwingAmount, float motionThreshold) { + Vec3d velocity = livingEntity.getVelocity(); + float averageVelocity = (MathHelper.abs((float) velocity.x) + MathHelper.abs((float) velocity.z)) / 2f; + return averageVelocity >= motionThreshold && limbSwingAmount != 0; + } +} diff --git a/src/main/java/com/mmodding/mmodding_lib/library/utils/CycledInteger.java b/src/main/java/com/mmodding/mmodding_lib/library/utils/CycledInteger.java index 2c68bdf..96e955e 100644 --- a/src/main/java/com/mmodding/mmodding_lib/library/utils/CycledInteger.java +++ b/src/main/java/com/mmodding/mmodding_lib/library/utils/CycledInteger.java @@ -1,7 +1,5 @@ package com.mmodding.mmodding_lib.library.utils; -import net.minecraft.util.math.MathHelper; - public class CycledInteger { private final int max; @@ -18,7 +16,7 @@ public CycledInteger(int value, int max) { } public int add(int value) { - return this.value = MathHelper.clamp(this.value + value, 0, this.max); + return this.value = this.value + value > this.max ? this.value + value - this.max : this.value + value; } public int get() {