GuiProfilerChartRenderer.java

net.minecraft.client.gui.render.pip.GuiProfilerChartRenderer

信息

  • 全限定名:net.minecraft.client.gui.render.pip.GuiProfilerChartRenderer
  • 类型:public class
  • 包:net.minecraft.client.gui.render.pip
  • 源码路径:src/main/java/net/minecraft/client/gui/render/pip/GuiProfilerChartRenderer.java
  • 起始行号:L16
  • 继承:PictureInPictureRenderer
  • 职责:

    TODO

字段/常量

内部类/嵌套类型

构造器

public GuiProfilerChartRenderer(MultiBufferSource.BufferSource bufferSource) @ L17

  • 构造器名:GuiProfilerChartRenderer
  • 源码定位:L17
  • 修饰符:public

参数:

  • bufferSource: MultiBufferSource.BufferSource

说明:

TODO

方法

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

public Class<GuiProfilerChartRenderState> getRenderStateClass() @ L21

  • 方法名:getRenderStateClass
  • 源码定位:L21
  • 返回类型:Class
  • 修饰符:public

参数:

说明:

TODO

protected void renderToTexture(GuiProfilerChartRenderState chartState, PoseStack poseStack) @ L26

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

参数:

  • chartState: GuiProfilerChartRenderState
  • poseStack: PoseStack

说明:

TODO

protected float getTranslateY(int height, int guiScale) @ L66

  • 方法名:getTranslateY
  • 源码定位:L66
  • 返回类型:float
  • 修饰符:protected

参数:

  • height: int
  • guiScale: int

说明:

TODO

protected String getTextureLabel() @ L71

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class GuiProfilerChartRenderer extends PictureInPictureRenderer<GuiProfilerChartRenderState> {
    public GuiProfilerChartRenderer(MultiBufferSource.BufferSource bufferSource) {
        super(bufferSource);
    }
 
    @Override
    public Class<GuiProfilerChartRenderState> getRenderStateClass() {
        return GuiProfilerChartRenderState.class;
    }
 
    protected void renderToTexture(GuiProfilerChartRenderState chartState, PoseStack poseStack) {
        double totalPercentage = 0.0;
        poseStack.translate(0.0F, -5.0F, 0.0F);
        Matrix4f pose = poseStack.last().pose();
 
        for (ResultField result : chartState.chartData()) {
            int steps = Mth.floor(result.percentage / 4.0) + 1;
            VertexConsumer buffer = this.bufferSource.getBuffer(RenderTypes.debugTriangleFan());
            int color = ARGB.opaque(result.getColor());
            int shadeColor = ARGB.multiply(color, -8355712);
            buffer.addVertex(pose, 0.0F, 0.0F, 0.0F).setColor(color);
 
            for (int j = steps; j >= 0; j--) {
                float dir = (float)((totalPercentage + result.percentage * j / steps) * (float) (Math.PI * 2) / 100.0);
                float xx = Mth.sin(dir) * 105.0F;
                float yy = Mth.cos(dir) * 105.0F * 0.5F;
                buffer.addVertex(pose, xx, yy, 0.0F).setColor(color);
            }
 
            buffer = this.bufferSource.getBuffer(RenderTypes.debugQuads());
 
            for (int j = steps; j > 0; j--) {
                float dir0 = (float)((totalPercentage + result.percentage * j / steps) * (float) (Math.PI * 2) / 100.0);
                float x0 = Mth.sin(dir0) * 105.0F;
                float y0 = Mth.cos(dir0) * 105.0F * 0.5F;
                float dir1 = (float)((totalPercentage + result.percentage * (j - 1) / steps) * (float) (Math.PI * 2) / 100.0);
                float x1 = Mth.sin(dir1) * 105.0F;
                float y1 = Mth.cos(dir1) * 105.0F * 0.5F;
                if (!((y0 + y1) / 2.0F < 0.0F)) {
                    buffer.addVertex(pose, x0, y0, 0.0F).setColor(shadeColor);
                    buffer.addVertex(pose, x0, y0 + 10.0F, 0.0F).setColor(shadeColor);
                    buffer.addVertex(pose, x1, y1 + 10.0F, 0.0F).setColor(shadeColor);
                    buffer.addVertex(pose, x1, y1, 0.0F).setColor(shadeColor);
                }
            }
 
            totalPercentage += result.percentage;
        }
    }
 
    @Override
    protected float getTranslateY(int height, int guiScale) {
        return height / 2.0F;
    }
 
    @Override
    protected String getTextureLabel() {
        return "profiler chart";
    }
}

引用的其他类