MineLittlePony/src/main/java/com/minelittlepony/client/model/IMobModel.java

36 lines
1.2 KiB
Java
Raw Normal View History

2019-03-23 20:49:34 +01:00
package com.minelittlepony.client.model;
2019-11-22 18:24:22 +01:00
import net.minecraft.client.model.ModelPart;
import net.minecraft.util.math.MathHelper;
2019-10-12 10:58:18 +02:00
import com.minelittlepony.model.PonyModelConstants;
2019-03-23 20:49:34 +01:00
/**
2019-10-12 10:58:18 +02:00
* Common interface for all undead enemies.
*/
2019-10-12 10:58:18 +02:00
public interface IMobModel {
2018-06-03 16:38:03 +02:00
/**
* 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
*/
2019-11-22 18:24:22 +01:00
default void rotateArmHolding(ModelPart arm, float direction, float swingProgress, float ticks) {
2019-10-12 10:58:18 +02:00
float swing = MathHelper.sin(swingProgress * PonyModelConstants.PI);
float roll = MathHelper.sin((1 - (1 - swingProgress) * (1 - swingProgress)) * PonyModelConstants.PI);
2018-06-03 16:38:03 +02:00
float cos = MathHelper.cos(ticks * 0.09F) * 0.05F + 0.05F;
float sin = MathHelper.sin(ticks * 0.067F) / 10;
2019-05-27 17:59:15 +02:00
arm.pitch = -1.5707964F;
arm.pitch -= swing * 1.2F - roll * 0.4F;
arm.pitch += sin;
2018-06-03 16:38:03 +02:00
2019-05-27 17:59:15 +02:00
arm.yaw = direction * (0.1F - swing * 0.6F);
arm.roll = cos;
2018-06-03 16:38:03 +02:00
}
}