diff options
author | ingle <inglettronald@gmail.com> | 2022-09-24 14:57:07 -0500 |
---|---|---|
committer | ingle <inglettronald@gmail.com> | 2022-09-24 14:57:07 -0500 |
commit | cce0c0c05e1f73902e474d9a63f6b1f302cd5176 (patch) | |
tree | 2a46288933f3a8c2a181d97e4ca157e1d04ece21 /src/main/java/dulkirmod | |
parent | 442926d9bcea191ac4f852d3d0770288c2a5bca7 (diff) | |
download | DulkirMod-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')
4 files changed, 67 insertions, 3 deletions
diff --git a/src/main/java/dulkirmod/mixins/ItemRendererMixin.java b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java new file mode 100644 index 0000000..9db5c9d --- /dev/null +++ b/src/main/java/dulkirmod/mixins/ItemRendererMixin.java @@ -0,0 +1,22 @@ +package dulkirmod.mixins; + +import dulkirmod.features.ItemAnimations; +import net.minecraft.client.renderer.ItemRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(value = {ItemRenderer.class}) +public class ItemRendererMixin { + + @Inject(method = {"transformFirstPersonItem(FF)V"}, at = @At("HEAD"), cancellable = true) + public void itemTransform(float equipProgress, float swingProgress, CallbackInfo ci) { + if (ItemAnimations.INSTANCE.itemTransforHook(equipProgress, swingProgress)) ci.cancel(); + } + + @Inject(method = {"doItemUsedTransformations"}, at = @At("HEAD"), cancellable = true) + public void useTransform(float swingProgress, CallbackInfo ci){ + if (ItemAnimations.INSTANCE.scaledSwing(swingProgress)) ci.cancel(); + } +} diff --git a/src/main/java/dulkirmod/mixins/MixinEntity.java b/src/main/java/dulkirmod/mixins/MixinEntity.java new file mode 100644 index 0000000..4116661 --- /dev/null +++ b/src/main/java/dulkirmod/mixins/MixinEntity.java @@ -0,0 +1,11 @@ +package dulkirmod.mixins; + +import net.minecraft.entity.Entity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; + +@Mixin(value = {Entity.class}, priority = 800) +public abstract class MixinEntity { + @Shadow + public abstract boolean equals(Object paramObject); +} 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)); + } +} diff --git a/src/main/java/dulkirmod/mixins/MixinRendererManager.java b/src/main/java/dulkirmod/mixins/MixinRendererManager.java index b545107..c695ed2 100644 --- a/src/main/java/dulkirmod/mixins/MixinRendererManager.java +++ b/src/main/java/dulkirmod/mixins/MixinRendererManager.java @@ -36,9 +36,9 @@ public class MixinRendererManager { NBTTagCompound properties = skullOwner.getCompoundTag("Properties"); if (properties.hasKey("textures")) { //if (properties.getTagList("textures", 10).tagCount() >= 1) { - if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" - .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value"))) - cir.cancel(); + if ("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTZjM2UzMWNmYzY2NzMzMjc1YzQyZmNmYjVkOWE0NDM0MmQ2NDNiNTVjZDE0YzljNzdkMjczYTIzNTIifX19" + .equals(properties.getTagList("textures", 10).getCompoundTagAt(0).getString("Value"))) + cir.cancel(); //} } |