mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2025-02-23 12:44:32 +01:00
41 lines
1.3 KiB
Java
41 lines
1.3 KiB
Java
package com.minelittlepony.client.model;
|
|
|
|
import net.minecraft.client.model.Cuboid;
|
|
import net.minecraft.entity.LivingEntity;
|
|
import net.minecraft.util.math.MathHelper;
|
|
|
|
import com.minelittlepony.client.model.races.ModelAlicorn;
|
|
|
|
/**
|
|
* Common class for all humanoid (ponioid?) non-player enemies.
|
|
*
|
|
*/
|
|
public abstract class ModelMobPony<T extends LivingEntity> extends ModelAlicorn<T> {
|
|
|
|
public ModelMobPony() {
|
|
super(false);
|
|
}
|
|
|
|
/**
|
|
* Rotates the provided arm to the correct orientation for holding an item.
|
|
*
|
|
* @param arm The arm to rotate
|
|
* @param direction Direction multiplier. 1 for right, -1 for left.
|
|
* @param swingProgress How far we are through the current swing
|
|
* @param ticks Render partial ticks
|
|
*/
|
|
protected void rotateArmHolding(Cuboid arm, float direction, float swingProgress, float ticks) {
|
|
float swing = MathHelper.sin(swingProgress * PI);
|
|
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PI);
|
|
|
|
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
|
|
float sin = MathHelper.sin(ticks * 0.067F) / 10;
|
|
|
|
arm.pitch = -1.5707964F;
|
|
arm.pitch -= swing * 1.2F - roll * 0.4F;
|
|
arm.pitch += sin;
|
|
|
|
arm.yaw = direction * (0.1F - swing * 0.6F);
|
|
arm.roll = cos;
|
|
}
|
|
}
|