mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-23 21:38:00 +01:00
Update dependencies
This commit is contained in:
parent
42f8a3c29b
commit
f45dbf08e2
9 changed files with 191 additions and 18 deletions
11
src/api/java/com/minelittlepony/MineLittlePony.java
Normal file
11
src/api/java/com/minelittlepony/MineLittlePony.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package com.minelittlepony;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class MineLittlePony {
|
||||
public static Object getConfig() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.minelittlepony.model.anim;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class BasicEasingInterpolator implements IInterpolator {
|
||||
|
||||
private final Map<String, Float> properties = new HashMap<String, Float>();
|
||||
|
||||
private float getLast(String key, float to) {
|
||||
if (properties.containsKey(key)) {
|
||||
return properties.get(key);
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float interpolate(String key, float to, float scalingFactor) {
|
||||
float from = getLast(key, to);
|
||||
|
||||
from += (to - from) / scalingFactor;
|
||||
|
||||
if (Float.isNaN(from) || Float.isInfinite(from)) {
|
||||
System.err.println("Error: Animation frame for " + key + " is NaN or Infinite.");
|
||||
from = to;
|
||||
}
|
||||
|
||||
properties.put(key, from);
|
||||
|
||||
return from;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.minelittlepony.model.anim;
|
||||
|
||||
/**
|
||||
* Interpolator function for handling transitions between animation states.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface IInterpolator {
|
||||
/**
|
||||
* Interpolates a value between the requested final destination and what it was last.
|
||||
*
|
||||
* @param key Identifier to track previous values
|
||||
* @param to The new values
|
||||
* @param scalingFactor Scaling factor to control how quickly values change
|
||||
*/
|
||||
float interpolate(String key, float to, float scalingFactor);
|
||||
}
|
17
src/api/java/com/minelittlepony/pony/data/IPony.java
Normal file
17
src/api/java/com/minelittlepony/pony/data/IPony.java
Normal file
|
@ -0,0 +1,17 @@
|
|||
package com.minelittlepony.pony.data;
|
||||
|
||||
import net.minecraft.client.entity.AbstractClientPlayer;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
// Stub
|
||||
@SideOnly(Side.CLIENT)
|
||||
public interface IPony {
|
||||
|
||||
static IPony forPlayer(AbstractClientPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PonyRace getRace(boolean ignorePony);
|
||||
|
||||
}
|
33
src/api/java/com/minelittlepony/pony/data/PonyRace.java
Normal file
33
src/api/java/com/minelittlepony/pony/data/PonyRace.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package com.minelittlepony.pony.data;
|
||||
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
// Stub
|
||||
@SideOnly(Side.CLIENT)
|
||||
public enum PonyRace {
|
||||
HUMAN,
|
||||
EARTH,
|
||||
PEGASUS,
|
||||
UNICORN,
|
||||
ALICORN,
|
||||
CHANGELING,
|
||||
ZEBRA,
|
||||
REFORMED_CHANGELING,
|
||||
GRIFFIN,
|
||||
HIPPOGRIFF,
|
||||
BATPONY,
|
||||
SEAPONY;
|
||||
|
||||
public boolean hasHorn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasWings() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isHuman() {
|
||||
return this == HUMAN;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.minelittlepony.transform;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
import com.minelittlepony.util.math.MathUtil;
|
||||
|
||||
public abstract class MotionCompositor {
|
||||
|
||||
protected double calculateRoll(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
||||
|
||||
// since model roll should probably be calculated from model rotation rather than entity rotation...
|
||||
double roll = MathUtil.sensibleAngle(player.prevRenderYawOffset - player.renderYawOffset);
|
||||
double horMotion = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
||||
float modelYaw = MathUtil.sensibleAngle(player.renderYawOffset);
|
||||
|
||||
// detecting that we're flying backwards and roll must be inverted
|
||||
if (Math.abs(MathUtil.sensibleAngle((float) Math.toDegrees(Math.atan2(motionX, motionZ)) + modelYaw)) > 90) {
|
||||
roll *= -1;
|
||||
}
|
||||
|
||||
// ayyy magic numbers (after 5 - an approximation of nice looking coefficients calculated by hand)
|
||||
|
||||
// roll might be zero, in which case Math.pow produces +Infinity. Anything x Infinity = NaN.
|
||||
double pow = roll != 0 ? Math.pow(Math.abs(roll), -0.191) : 0;
|
||||
|
||||
roll *= horMotion * 5 * (3.6884f * pow);
|
||||
|
||||
assert !Float.isNaN((float)roll);
|
||||
|
||||
return MathHelper.clamp(roll, -54, 54);
|
||||
}
|
||||
|
||||
protected double calculateIncline(EntityPlayer player, double motionX, double motionY, double motionZ) {
|
||||
double dist = Math.sqrt(motionX * motionX + motionZ * motionZ);
|
||||
double angle = Math.atan2(motionY, dist);
|
||||
|
||||
if (!player.capabilities.isFlying) {
|
||||
angle /= 2;
|
||||
}
|
||||
|
||||
angle = MathUtil.clampLimit(angle, Math.PI / 3);
|
||||
|
||||
return Math.toDegrees(angle);
|
||||
}
|
||||
|
||||
}
|
32
src/api/java/com/minelittlepony/util/math/MathUtil.java
Normal file
32
src/api/java/com/minelittlepony/util/math/MathUtil.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package com.minelittlepony.util.math;
|
||||
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
|
||||
public class MathUtil {
|
||||
|
||||
public static double clampLimit(double num, double limit) {
|
||||
return MathHelper.clamp(num, -limit, limit);
|
||||
}
|
||||
|
||||
public static float sensibleAngle(float angle) {
|
||||
angle %= 360;
|
||||
|
||||
if (angle > 180) angle -= 360;
|
||||
if (angle < -180) angle += 360;
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
public static float interpolateDegress(float prev, float current, float partialTicks) {
|
||||
float difference = current - prev;
|
||||
|
||||
while (difference < -180) difference += 360;
|
||||
while (difference >= 180) difference -= 360;
|
||||
|
||||
return prev + partialTicks * difference;
|
||||
}
|
||||
|
||||
public static float interpolateRadians(float prev, float current, float partialTicks) {
|
||||
return (float)Math.toRadians(interpolateDegress(prev, current, partialTicks));
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.minelittlepony.util.render;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
/**
|
||||
* A texture pool for generating multiple associated textures.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ITextureSupplier<T> {
|
||||
ResourceLocation supplyTexture(T key);
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
@MethodsReturnNonnullByDefault
|
||||
@ParametersAreNonnullByDefault
|
||||
package com.minelittlepony.util.render;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
Loading…
Reference in a new issue