Use relative time offset, rather than absolute value, for animations (#4635)

This commit is contained in:
Ben Staddon authored and LexManos committed 2018-01-28 23:19:16 -08:00
1 parent c12df92170
commit 0e3f46c74b
1 file changed
+11 -1
@@ -21,12 +21,17 @@ package net.minecraftforge.client.model.animation;
import net.minecraft.world.World;
import java.lang.ref.WeakReference;
public enum Animation
{
INSTANCE;
private float clientPartialTickTime;
private static long epochTime;
private static WeakReference<World> worldRef;
/**
* Get the global world time for the current tick, in seconds.
*/
@@ -40,7 +45,12 @@ public enum Animation
*/
public static float getWorldTime(World world, float tickProgress)
{
return (world.getTotalWorldTime() + tickProgress) / 20;
if (worldRef == null || worldRef.get() != world)
{
epochTime = world.getTotalWorldTime();
worldRef = new WeakReference<>(world);
}
return (world.getTotalWorldTime() - epochTime + tickProgress) / 20;
}
/**