Skip to content

Commit

Permalink
Revert "Fix playeranimator dependency issue"
Browse files Browse the repository at this point in the history
This reverts commit 8e78881.
  • Loading branch information
iron431 committed May 28, 2023
1 parent 5677e6d commit 199085c
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<ResourceLocation> 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());
Expand All @@ -33,17 +39,48 @@ public void getCloakTextureLocation(CallbackInfoReturnable<ResourceLocation> cir

@Inject(method = "isCapeLoaded", at = @At(value = "HEAD"), cancellable = true)
public void isCapeLoaded(CallbackInfoReturnable<Boolean> 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);
}
}

@Inject(method = "<init>", 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<IAnimation>) 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;
}
});
}

}

}

This file was deleted.

0 comments on commit 199085c

Please sign in to comment.