From 199085cdbced5ba674dfb1988cc66bc3e94c9180 Mon Sep 17 00:00:00 2001 From: Christian Date: Sun, 28 May 2023 13:40:52 -0500 Subject: [PATCH] Revert "Fix playeranimator dependency issue" This reverts commit 8e78881782b68c4fc73d41c4957c66ddd678c731. --- .../mixin/AbstractClientPlayerMixin.java | 49 +++++++++++++++--- .../AbstractClientPlayerMixinHelper.java | 51 ------------------- 2 files changed, 43 insertions(+), 57 deletions(-) delete mode 100644 src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixinHelper.java diff --git a/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixin.java b/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixin.java index 9b4468f63..c915f9283 100644 --- a/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixin.java +++ b/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixin.java @@ -1,6 +1,12 @@ package io.redspace.ironsspellbooks.mixin; import com.mojang.authlib.GameProfile; +import dev.kosmx.playerAnim.api.layered.IAnimation; +import dev.kosmx.playerAnim.api.layered.ModifierLayer; +import dev.kosmx.playerAnim.api.layered.modifier.AdjustmentModifier; +import dev.kosmx.playerAnim.api.layered.modifier.MirrorModifier; +import dev.kosmx.playerAnim.core.util.Vec3f; +import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess; import io.redspace.ironsspellbooks.item.armor.ArmorCapeProvider; import io.redspace.ironsspellbooks.registries.MobEffectRegistry; import io.redspace.ironsspellbooks.spells.AbstractSpell; @@ -20,11 +26,11 @@ import java.util.Optional; @Mixin(AbstractClientPlayer.class) -public class AbstractClientPlayerMixin { +public class AbstractClientPlayerMixin{ @Inject(method = "getCloakTextureLocation", at = @At(value = "HEAD"), cancellable = true) public void getCloakTextureLocation(CallbackInfoReturnable cir) { - var player = (Player) (Object) this; + var player = (Player) (Object)this; ItemStack itemstack = player.getItemBySlot(EquipmentSlot.CHEST); if (itemstack.getItem() instanceof ArmorCapeProvider capeProvider && !player.hasEffect(MobEffectRegistry.ANGEL_WINGS.get())) { cir.setReturnValue(capeProvider.getCapeResourceLocation()); @@ -33,7 +39,7 @@ public void getCloakTextureLocation(CallbackInfoReturnable cir @Inject(method = "isCapeLoaded", at = @At(value = "HEAD"), cancellable = true) public void isCapeLoaded(CallbackInfoReturnable cir) { - var player = (Player) (Object) this; + var player = (Player) (Object)this; ItemStack itemstack = player.getItemBySlot(EquipmentSlot.CHEST); if (itemstack.getItem() instanceof ArmorCapeProvider capeProvider) { cir.setReturnValue(true); @@ -41,9 +47,40 @@ public void isCapeLoaded(CallbackInfoReturnable cir) { } @Inject(method = "", at = @At("TAIL")) - private void postInit(ClientLevel world, GameProfile profile, ProfilePublicKey publicKey, CallbackInfo ci) { - var player = (Player) (Object) this; - AbstractClientPlayerMixinHelper.playerMixinInit(player); + private void postInit(ClientLevel pClientLevel, GameProfile pGameProfile, CallbackInfo ci) { + var player = (Player) (Object)this; + var animation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData((AbstractClientPlayer) player).get(AbstractSpell.ANIMATION_RESOURCE); + if (animation != null ) { + animation.addModifierLast(new AdjustmentModifier((partName) -> { + float rotationX = 0; + float rotationY = 0; + float rotationZ = 0; + float offsetX = 0; + float offsetY = 0; + float offsetZ = 0; + var pitch = player.getXRot(); + var yaw = player.yHeadRot - player.yBodyRot; + pitch = (float) Math.toRadians(pitch); + yaw = (float) Math.toRadians(yaw); + switch (partName) { + case "rightArm", "leftArm" -> { + rotationX = pitch; + rotationY = yaw; + } + default -> { + return Optional.empty(); + } + } + return Optional.of(new AdjustmentModifier.PartModifier(new Vec3f(rotationX, rotationY, rotationZ), new Vec3f(offsetX, offsetY, offsetZ))); + })); + animation.addModifierLast(new MirrorModifier(){ + @Override + public boolean isEnabled() { + return player.getUsedItemHand() == InteractionHand.OFF_HAND; + } + }); + } + } } diff --git a/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixinHelper.java b/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixinHelper.java deleted file mode 100644 index 7312b962c..000000000 --- a/src/main/java/io/redspace/ironsspellbooks/mixin/AbstractClientPlayerMixinHelper.java +++ /dev/null @@ -1,51 +0,0 @@ -package io.redspace.ironsspellbooks.mixin; - -import dev.kosmx.playerAnim.api.layered.IAnimation; -import dev.kosmx.playerAnim.api.layered.ModifierLayer; -import dev.kosmx.playerAnim.api.layered.modifier.AdjustmentModifier; -import dev.kosmx.playerAnim.api.layered.modifier.MirrorModifier; -import dev.kosmx.playerAnim.core.util.Vec3f; -import dev.kosmx.playerAnim.minecraftApi.PlayerAnimationAccess; -import io.redspace.ironsspellbooks.spells.AbstractSpell; -import net.minecraft.client.player.AbstractClientPlayer; -import net.minecraft.world.InteractionHand; -import net.minecraft.world.entity.player.Player; - -import java.util.Optional; - -public class AbstractClientPlayerMixinHelper { - - public static void playerMixinInit(Player player) { - var animation = (ModifierLayer) PlayerAnimationAccess.getPlayerAssociatedData((AbstractClientPlayer) player).get(AbstractSpell.ANIMATION_RESOURCE); - if (animation != null) { - animation.addModifierLast(new AdjustmentModifier((partName) -> { - float rotationX = 0; - float rotationY = 0; - float rotationZ = 0; - float offsetX = 0; - float offsetY = 0; - float offsetZ = 0; - var pitch = player.getXRot(); - var yaw = player.yHeadRot - player.yBodyRot; - pitch = (float) Math.toRadians(pitch); - yaw = (float) Math.toRadians(yaw); - switch (partName) { - case "rightArm", "leftArm" -> { - rotationX = pitch; - rotationY = yaw; - } - default -> { - return Optional.empty(); - } - } - return Optional.of(new AdjustmentModifier.PartModifier(new Vec3f(rotationX, rotationY, rotationZ), new Vec3f(offsetX, offsetY, offsetZ))); - })); - animation.addModifierLast(new MirrorModifier() { - @Override - public boolean isEnabled() { - return player.getUsedItemHand() == InteractionHand.OFF_HAND; - } - }); - } - } -}