FpsDebugChart.java

net.minecraft.client.gui.components.debugchart.FpsDebugChart

信息

  • 全限定名:net.minecraft.client.gui.components.debugchart.FpsDebugChart
  • 类型:public class
  • 包:net.minecraft.client.gui.components.debugchart
  • 源码路径:src/main/java/net/minecraft/client/gui/components/debugchart/FpsDebugChart.java
  • 起始行号:L12
  • 继承:AbstractDebugChart
  • 职责:

    TODO

字段/常量

  • CHART_TOP_FPS

    • 类型: int
    • 修饰符: private static final
    • 源码定位: L13
    • 说明:

      TODO

  • CHART_TOP_VALUE

    • 类型: double
    • 修饰符: private static final
    • 源码定位: L14
    • 说明:

      TODO

内部类/嵌套类型

构造器

public FpsDebugChart(Font font, SampleStorage sampleStorage) @ L16

  • 构造器名:FpsDebugChart
  • 源码定位:L16
  • 修饰符:public

参数:

  • font: Font
  • sampleStorage: SampleStorage

说明:

TODO

方法

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

protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) @ L20

  • 方法名:extractAdditionalLinesAndLabels
  • 源码定位:L20
  • 返回类型:void
  • 修饰符:protected

参数:

  • graphics: GuiGraphicsExtractor
  • left: int
  • width: int
  • bottom: int

说明:

TODO

protected String toDisplayString(double nanos) @ L31

  • 方法名:toDisplayString
  • 源码定位:L31
  • 返回类型:String
  • 修饰符:protected

参数:

  • nanos: double

说明:

TODO

protected int getSampleHeight(double nanos) @ L36

  • 方法名:getSampleHeight
  • 源码定位:L36
  • 返回类型:int
  • 修饰符:protected

参数:

  • nanos: double

说明:

TODO

protected int getSampleColor(long nanos) @ L41

  • 方法名:getSampleColor
  • 源码定位:L41
  • 返回类型:int
  • 修饰符:protected

参数:

  • nanos: long

说明:

TODO

private static double toMilliseconds(double nanos) @ L46

  • 方法名:toMilliseconds
  • 源码定位:L46
  • 返回类型:double
  • 修饰符:private static

参数:

  • nanos: double

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class FpsDebugChart extends AbstractDebugChart {
    private static final int CHART_TOP_FPS = 30;
    private static final double CHART_TOP_VALUE = 33.333333333333336;
 
    public FpsDebugChart(Font font, SampleStorage sampleStorage) {
        super(font, sampleStorage);
    }
 
    @Override
    protected void extractAdditionalLinesAndLabels(GuiGraphicsExtractor graphics, int left, int width, int bottom) {
        this.extractStringWithShade(graphics, "30 FPS", left + 1, bottom - 60 + 1);
        this.extractStringWithShade(graphics, "60 FPS", left + 1, bottom - 30 + 1);
        graphics.horizontalLine(left, left + width - 1, bottom - 30, -1);
        int framerateLimit = Minecraft.getInstance().options.framerateLimit().get();
        if (framerateLimit > 0 && framerateLimit <= 250) {
            graphics.horizontalLine(left, left + width - 1, bottom - this.getSampleHeight(1.0E9 / framerateLimit) - 1, -16711681);
        }
    }
 
    @Override
    protected String toDisplayString(double nanos) {
        return String.format(Locale.ROOT, "%d ms", (int)Math.round(toMilliseconds(nanos)));
    }
 
    @Override
    protected int getSampleHeight(double nanos) {
        return (int)Math.round(toMilliseconds(nanos) * 60.0 / 33.333333333333336);
    }
 
    @Override
    protected int getSampleColor(long nanos) {
        return this.getSampleColor(toMilliseconds(nanos), 0.0, -16711936, 28.0, -256, 56.0, -65536);
    }
 
    private static double toMilliseconds(double nanos) {
        return nanos / 1000000.0;
    }
}

引用的其他类