DeltaTracker.java

net.minecraft.client.DeltaTracker

信息

  • 全限定名:net.minecraft.client.DeltaTracker
  • 类型:public interface
  • 包:net.minecraft.client
  • 源码路径:src/main/java/net/minecraft/client/DeltaTracker.java
  • 起始行号:L8
  • 职责:

    TODO

字段/常量

  • ZERO

    • 类型: DeltaTracker
    • 修饰符: package-private
    • 源码定位: L9
    • 说明:

      TODO

  • ONE

    • 类型: DeltaTracker
    • 修饰符: package-private
    • 源码定位: L10
    • 说明:

      TODO

内部类/嵌套类型

  • net.minecraft.client.DeltaTracker.DefaultValue

    • 类型: class
    • 修饰符: public static
    • 源码定位: L19
    • 说明:

      TODO

  • net.minecraft.client.DeltaTracker.Timer

    • 类型: class
    • 修饰符: public static
    • 源码定位: L43
    • 说明:

      TODO

构造器

方法

下面的方法块按源码顺序生成。

float getGameTimeDeltaTicks() @ L12

  • 方法名:getGameTimeDeltaTicks
  • 源码定位:L12
  • 返回类型:float
  • 修饰符:package-private

参数:

说明:

TODO

float getGameTimeDeltaPartialTick(boolean ignoreFrozenGame) @ L14

  • 方法名:getGameTimeDeltaPartialTick
  • 源码定位:L14
  • 返回类型:float
  • 修饰符:package-private

参数:

  • ignoreFrozenGame: boolean

说明:

TODO

float getRealtimeDeltaTicks() @ L16

  • 方法名:getRealtimeDeltaTicks
  • 源码定位:L16
  • 返回类型:float
  • 修饰符:package-private

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public interface DeltaTracker {
    DeltaTracker ZERO = new DeltaTracker.DefaultValue(0.0F);
    DeltaTracker ONE = new DeltaTracker.DefaultValue(1.0F);
 
    float getGameTimeDeltaTicks();
 
    float getGameTimeDeltaPartialTick(boolean ignoreFrozenGame);
 
    float getRealtimeDeltaTicks();
 
    @OnlyIn(Dist.CLIENT)
    public static class DefaultValue implements DeltaTracker {
        private final float value;
 
        private DefaultValue(float value) {
            this.value = value;
        }
 
        @Override
        public float getGameTimeDeltaTicks() {
            return this.value;
        }
 
        @Override
        public float getGameTimeDeltaPartialTick(boolean ignored) {
            return this.value;
        }
 
        @Override
        public float getRealtimeDeltaTicks() {
            return this.value;
        }
    }
 
    @OnlyIn(Dist.CLIENT)
    public static class Timer implements DeltaTracker {
        private float deltaTicks;
        private float deltaTickResidual;
        private float realtimeDeltaTicks;
        private float pausedDeltaTickResidual;
        private long lastMs;
        private long lastUiMs;
        private final float msPerTick;
        private final FloatUnaryOperator targetMsptProvider;
        private boolean paused;
        private boolean frozen;
 
        public Timer(float ticksPerSecond, long currentMs, FloatUnaryOperator targetMsptProvider) {
            this.msPerTick = 1000.0F / ticksPerSecond;
            this.lastUiMs = this.lastMs = currentMs;
            this.targetMsptProvider = targetMsptProvider;
        }
 
        public int advanceGameTime(long currentMs) {
            this.deltaTicks = (float)(currentMs - this.lastMs) / this.targetMsptProvider.apply(this.msPerTick);
            this.lastMs = currentMs;
            this.deltaTickResidual = this.deltaTickResidual + this.deltaTicks;
            int ticks = (int)this.deltaTickResidual;
            this.deltaTickResidual -= ticks;
            return ticks;
        }
 
        public void advanceRealTime(long currentMs) {
            this.realtimeDeltaTicks = (float)(currentMs - this.lastUiMs) / this.msPerTick;
            this.lastUiMs = currentMs;
        }
 
        public void updatePauseState(boolean pauseState) {
            if (pauseState) {
                this.pause();
            } else {
                this.unPause();
            }
        }
 
        private void pause() {
            if (!this.paused) {
                this.pausedDeltaTickResidual = this.deltaTickResidual;
            }
 
            this.paused = true;
        }
 
        private void unPause() {
            if (this.paused) {
                this.deltaTickResidual = this.pausedDeltaTickResidual;
            }
 
            this.paused = false;
        }
 
        public void updateFrozenState(boolean frozen) {
            this.frozen = frozen;
        }
 
        @Override
        public float getGameTimeDeltaTicks() {
            return this.deltaTicks;
        }
 
        @Override
        public float getGameTimeDeltaPartialTick(boolean ignoreFrozenGame) {
            if (!ignoreFrozenGame && this.frozen) {
                return 1.0F;
            } else {
                return this.paused ? this.pausedDeltaTickResidual : this.deltaTickResidual;
            }
        }
 
        @Override
        public float getRealtimeDeltaTicks() {
            return this.realtimeDeltaTicks > 7.0F ? 0.5F : this.realtimeDeltaTicks;
        }
    }
}

引用的其他类