mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 04:32:15 +00:00
Use relative time offset, rather than absolute value, for animations (#4635)
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user