Ejemplo n.º 1
0
        /// <summary>
        /// Updates all fields of the Timer using the current time
        /// </summary>
        public virtual void UpdateTimer()
        {
            long   l  = JavaHelper.CurrentTimeMillis();
            long   l1 = l - LastSyncSysClock;
            long   l2 = JavaHelper.NanoTime() / 0xf4240L;
            double d  = (double)l2 / 1000D;

            if (l1 > 1000L)
            {
                LastHRTime = d;
            }
            else if (l1 < 0L)
            {
                LastHRTime = d;
            }
            else
            {
                Field_28132_i += l1;

                if (Field_28132_i > 1000L)
                {
                    long   l3 = l2 - LastSyncHRClock;
                    double d2 = (double)Field_28132_i / (double)l3;
                    TimeSyncAdjustment += (d2 - TimeSyncAdjustment) * 0.20000000298023224D;
                    LastSyncHRClock     = l2;
                    Field_28132_i       = 0L;
                }

                if (Field_28132_i < 0L)
                {
                    LastSyncHRClock = l2;
                }
            }

            LastSyncSysClock = l;
            double d1 = (d - LastHRTime) * TimeSyncAdjustment;

            LastHRTime = d;

            if (d1 < 0.0F)
            {
                d1 = 0.0F;
            }

            if (d1 > 1.0D)
            {
                d1 = 1.0D;
            }

            ElapsedPartialTicks += (float)d1 * TimerSpeed * TicksPerSecond;
            ElapsedTicks         = (int)ElapsedPartialTicks;
            ElapsedPartialTicks -= ElapsedTicks;

            if (ElapsedTicks > 10)
            {
                ElapsedTicks = 10;
            }

            RenderPartialTicks = ElapsedPartialTicks;
        }
Ejemplo n.º 2
0
 public Timer(float par1)
 {
     TimerSpeed          = 1.0F;
     ElapsedPartialTicks = 0.0F;
     TimeSyncAdjustment  = 1.0D;
     TicksPerSecond      = par1;
     LastSyncSysClock    = JavaHelper.CurrentTimeMillis();
     LastSyncHRClock     = JavaHelper.NanoTime() / 0xf4240L;
 }