From cce0c0c05e1f73902e474d9a63f6b1f302cd5176 Mon Sep 17 00:00:00 2001 From: ingle Date: Sat, 24 Sep 2022 14:57:07 -0500 Subject: Imported customAnimations courtesy of Aton. Also add Nametag Cleaner. --- .../java/dulkirmod/mixins/ItemRendererMixin.java | 22 +++++++++++++++ src/main/java/dulkirmod/mixins/MixinEntity.java | 11 ++++++++ .../dulkirmod/mixins/MixinEntityLivingBase.java | 31 ++++++++++++++++++++++ .../dulkirmod/mixins/MixinRendererManager.java | 6 ++--- 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 src/main/java/dulkirmod/mixins/ItemRendererMixin.java create mode 100644 src/main/java/dulkirmod/mixins/MixinEntity.java create mode 100644 src/main/java/dulkirmod/mixins/MixinEntityLivingBase.java (limited to 'src/main/java/dulkirmod') 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 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(); //} } -- cgit