package com.minelittlepony.client.model.entity;

import com.minelittlepony.client.model.IMobModel;
import com.minelittlepony.client.model.entity.race.ModelAlicorn;
import com.minelittlepony.mson.api.model.MsonPart;

import net.minecraft.entity.mob.HostileEntity;
import net.minecraft.util.math.MathHelper;

public class ModelZombiePony<Zombie extends HostileEntity> extends ModelAlicorn<Zombie> implements IMobModel {

    private boolean isPegasus;

    public ModelZombiePony() {
        super(false);
    }

    @Override
    public void animateModel(Zombie entity, float move, float swing, float ticks) {
        isPegasus = entity.getUuid().getLeastSignificantBits() % 30 == 0;
    }

    @Override
    protected void rotateLegs(float move, float swing, float ticks, Zombie entity) {
        super.rotateLegs(move, swing, ticks, entity);

        if (rightArmPose == ArmPose.EMPTY) {
            if (islookAngleRight(move)) {
                rotateArmHolding(rightArm, 1, getSwingAmount(), ticks);
                ((MsonPart)rightArm).shift(0.5F, 1.5F, 3);
            } else {
                rotateArmHolding(leftArm, -1, getSwingAmount(), ticks);
                ((MsonPart)leftArm).shift(-0.5F, 1.5F, 3);
            }
        }
    }

    public boolean islookAngleRight(float move) {
        return MathHelper.sin(move / 20) < 0;
    }

    @Override
    public boolean canFly() {
        return isPegasus;
    }
}
