package tld.testmod.common.animation;

import net.minecraft.world.World;
import net.minecraftforge.client.model.animation.Animation;

public enum ModAnimation
{

    INSTANCE;
    static long timeOffset;
    static int lastWorldHashCode;
    
    /**
     * Get the global world time for the current tick, in seconds.
     */
    public static float getWorldTime(World world)
    {
        return getWorldTime(world, 0);
    }

    /**
     * Get the global world time for the current tick + partial tick progress, in seconds.
     */
    public static float getWorldTime(World world, float tickProgress)
    {
        int worldHashCode = world.hashCode();
        if (worldHashCode != lastWorldHashCode)
        {
            timeOffset = world.getTotalWorldTime();
            lastWorldHashCode = worldHashCode;
        }
        //long diff = world.getTotalWorldTime() - timeOffset;
        //ModLogger.info("Animation#getWorldTime: World: %s, time: %d, offset %d, diff: %d", lastWorldHashCode, world.getTotalWorldTime(), timeOffset, diff);
        return (world.getTotalWorldTime() - timeOffset  + tickProgress) / 20;
    }

    /**
     * Get current partialTickTime.
     */
    public static float getPartialTickTime()
    {
        return Animation.getPartialTickTime();
    }
    
}

@@ -216,29 +216,45 @@
 int last
-WorldHashCode
+Dimension = Integer.MAX_VALUE
 ;%0A    %0A 
@@ -636,88 +636,89 @@
 int 
-worldHashCode = world.hashCode();%0A        if (worldHashCode != lastWorldHashCode
+dimension = world.provider.getDimension();%0A        if (dimension != lastDimension
 )%0A  
@@ -797,37 +797,29 @@
 last
-WorldHashCode = worldHashCode
+Dimension = dimension
 ;%0A  
@@ -942,17 +942,21 @@
 me: 
-World: %25s
+Dimension: %25d
 , ti
@@ -993,21 +993,17 @@
 last
-WorldHashCode
+Dimension
 , wo

Store last world dimension and compare with current to determine if world changed. If so update the time offset.