diff --git a/src/main/java/net/minecraftforge/client/model/animation/Animation.java b/src/main/java/net/minecraftforge/client/model/animation/Animation.java index 958f19c956..623f05b0d1 100644 --- a/src/main/java/net/minecraftforge/client/model/animation/Animation.java +++ b/src/main/java/net/minecraftforge/client/model/animation/Animation.java @@ -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 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; } /**