aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
diff options
context:
space:
mode:
authoringle <inglettronald@gmail.com>2022-09-24 14:57:07 -0500
committeringle <inglettronald@gmail.com>2022-09-24 14:57:07 -0500
commitcce0c0c05e1f73902e474d9a63f6b1f302cd5176 (patch)
tree2a46288933f3a8c2a181d97e4ca157e1d04ece21 /src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java
parent442926d9bcea191ac4f852d3d0770288c2a5bca7 (diff)
downloadDulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.tar.gz
DulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.tar.bz2
DulkirMod-cce0c0c05e1f73902e474d9a63f6b1f302cd5176.zip
Imported customAnimations courtesy of Aton.
Also add Nametag Cleaner.
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));
+ }
+}