aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java')
-rw-r--r--src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
new file mode 100644
index 0000000..43a6c27
--- /dev/null
+++ b/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
@@ -0,0 +1,31 @@
+package dulkirmod.mixins;
+
+
+import dulkirmod.DulkirMod;
+import net.minecraft.entity.EntityLivingBase;
+import net.minecraft.potion.Potion;
+import net.minecraft.potion.PotionEffect;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+@Mixin({EntityLivingBase.class})
+public abstract class MixinEntityLivingBase extends MixinEntity {
+
+ @Shadow public abstract boolean isPotionActive(Potion potionIn);
+
+ @Shadow public abstract PotionEffect getActivePotionEffect(Potion potionIn);
+
+ @Inject(method = {"getArmSwingAnimationEnd()I"}, at = @At("HEAD"), cancellable = true)
+ public void adjustSwingLength(CallbackInfoReturnable<Integer> cir) {
+ if (!DulkirMod.Companion.getConfig().getCustomAnimations()) return;
+ int length = DulkirMod.Companion.getConfig().getIgnoreHaste() ? 6 : this.isPotionActive(Potion.digSpeed) ?
+ 6 - (1 + this.getActivePotionEffect(Potion.digSpeed).getAmplifier()) :
+ (this.isPotionActive(Potion.digSlowdown) ?
+ 6 + (1 + this.getActivePotionEffect(Potion.digSlowdown).getAmplifier()) * 2 :
+ 6);
+ cir.setReturnValue(Math.max((int)(length* Math.exp(-DulkirMod.Companion.getConfig().getCustomSpeed())), 1));
+ }
+}