PoiDebugRenderer.java

net.minecraft.client.renderer.debug.PoiDebugRenderer

信息

  • 全限定名:net.minecraft.client.renderer.debug.PoiDebugRenderer
  • 类型:public class
  • 包:net.minecraft.client.renderer.debug
  • 源码路径:src/main/java/net/minecraft/client/renderer/debug/PoiDebugRenderer.java
  • 起始行号:L19
  • 实现:DebugRenderer.SimpleDebugRenderer
  • 职责:

    TODO

字段/常量

  • MAX_RENDER_DIST_FOR_POI_INFO

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

      TODO

  • TEXT_SCALE

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

      TODO

  • ORANGE

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

      TODO

  • brainRenderer

    • 类型: BrainDebugRenderer
    • 修饰符: private final
    • 源码定位: L23
    • 说明:

      TODO

内部类/嵌套类型

构造器

public PoiDebugRenderer(BrainDebugRenderer brainRenderer) @ L25

  • 构造器名:PoiDebugRenderer
  • 源码定位:L25
  • 修饰符:public

参数:

  • brainRenderer: BrainDebugRenderer

说明:

TODO

方法

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

public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) @ L29

  • 方法名:emitGizmos
  • 源码定位:L29
  • 返回类型:void
  • 修饰符:public

参数:

  • camX: double
  • camY: double
  • camZ: double
  • debugValues: DebugValueAccess
  • frustum: Frustum
  • partialTicks: float

说明:

TODO

private static void highlightPoi(BlockPos poiPos) @ L47

  • 方法名:highlightPoi
  • 源码定位:L47
  • 返回类型:void
  • 修饰符:private static

参数:

  • poiPos: BlockPos

说明:

TODO

private void renderGhostPoi(BlockPos poiPos, List<String> names) @ L52

  • 方法名:renderGhostPoi
  • 源码定位:L52
  • 返回类型:void
  • 修饰符:private

参数:

  • poiPos: BlockPos
  • names: List

说明:

TODO

private void renderPoiInfo(DebugPoiInfo poi, DebugValueAccess debugValues) @ L59

  • 方法名:renderPoiInfo
  • 源码定位:L59
  • 返回类型:void
  • 修饰符:private

参数:

  • poi: DebugPoiInfo
  • debugValues: DebugValueAccess

说明:

TODO

private static void renderTextOverPoi(String text, DebugPoiInfo poi, int row, int color) @ L84

  • 方法名:renderTextOverPoi
  • 源码定位:L84
  • 返回类型:void
  • 修饰符:private static

参数:

  • text: String
  • poi: DebugPoiInfo
  • row: int
  • color: int

说明:

TODO

private List<String> getTicketHolderNames(DebugPoiInfo poi, boolean potential, DebugValueAccess debugValues) @ L88

  • 方法名:getTicketHolderNames
  • 源码定位:L88
  • 返回类型:List
  • 修饰符:private

参数:

  • poi: DebugPoiInfo
  • potential: boolean
  • debugValues: DebugValueAccess

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class PoiDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
    private static final int MAX_RENDER_DIST_FOR_POI_INFO = 30;
    private static final float TEXT_SCALE = 0.32F;
    private static final int ORANGE = -23296;
    private final BrainDebugRenderer brainRenderer;
 
    public PoiDebugRenderer(BrainDebugRenderer brainRenderer) {
        this.brainRenderer = brainRenderer;
    }
 
    @Override
    public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
        BlockPos playerPos = BlockPos.containing(camX, camY, camZ);
        debugValues.forEachBlock(DebugSubscriptions.POIS, (pos, poi) -> {
            if (playerPos.closerThan(pos, 30.0)) {
                highlightPoi(pos);
                this.renderPoiInfo(poi, debugValues);
            }
        });
        this.brainRenderer.getGhostPois(debugValues).forEach((poiPos, value) -> {
            if (debugValues.getBlockValue(DebugSubscriptions.POIS, poiPos) == null) {
                if (playerPos.closerThan(poiPos, 30.0)) {
                    this.renderGhostPoi(poiPos, (List<String>)value);
                }
            }
        });
    }
 
    private static void highlightPoi(BlockPos poiPos) {
        float padding = 0.05F;
        Gizmos.cuboid(poiPos, 0.05F, GizmoStyle.fill(ARGB.colorFromFloat(0.3F, 0.2F, 0.2F, 1.0F)));
    }
 
    private void renderGhostPoi(BlockPos poiPos, List<String> names) {
        float padding = 0.05F;
        Gizmos.cuboid(poiPos, 0.05F, GizmoStyle.fill(ARGB.colorFromFloat(0.3F, 0.2F, 0.2F, 1.0F)));
        Gizmos.billboardTextOverBlock(names.toString(), poiPos, 0, -256, 0.32F);
        Gizmos.billboardTextOverBlock("Ghost POI", poiPos, 1, -65536, 0.32F);
    }
 
    private void renderPoiInfo(DebugPoiInfo poi, DebugValueAccess debugValues) {
        int row = 0;
        if (SharedConstants.DEBUG_BRAIN) {
            List<String> ticketHolderNames = this.getTicketHolderNames(poi, false, debugValues);
            if (ticketHolderNames.size() < 4) {
                renderTextOverPoi("Owners: " + ticketHolderNames, poi, row, -256);
            } else {
                renderTextOverPoi(ticketHolderNames.size() + " ticket holders", poi, row, -256);
            }
 
            row++;
            List<String> potentialTicketHolderNames = this.getTicketHolderNames(poi, true, debugValues);
            if (potentialTicketHolderNames.size() < 4) {
                renderTextOverPoi("Candidates: " + potentialTicketHolderNames, poi, row, -23296);
            } else {
                renderTextOverPoi(potentialTicketHolderNames.size() + " potential owners", poi, row, -23296);
            }
 
            row++;
        }
 
        renderTextOverPoi("Free tickets: " + poi.freeTicketCount(), poi, row, -256);
        renderTextOverPoi(poi.poiType().getRegisteredName(), poi, ++row, -1);
    }
 
    private static void renderTextOverPoi(String text, DebugPoiInfo poi, int row, int color) {
        Gizmos.billboardTextOverBlock(text, poi.pos(), row, color, 0.32F);
    }
 
    private List<String> getTicketHolderNames(DebugPoiInfo poi, boolean potential, DebugValueAccess debugValues) {
        List<String> names = new ArrayList<>();
        debugValues.forEachEntity(DebugSubscriptions.BRAINS, (entity, brainDump) -> {
            boolean include = potential ? brainDump.hasPotentialPoi(poi.pos()) : brainDump.hasPoi(poi.pos());
            if (include) {
                names.add(DebugEntityNameGenerator.getEntityName(entity.getUUID()));
            }
        });
        return names;
    }
}

引用的其他类

  • Frustum

    • 引用位置: 参数
  • BrainDebugRenderer

    • 引用位置: 参数/字段
  • DebugRenderer

    • 引用位置: 实现
  • BlockPos

    • 引用位置: 参数/方法调用
    • 关联成员: BlockPos.containing()
  • GizmoStyle

    • 引用位置: 方法调用
    • 关联成员: GizmoStyle.fill()
  • Gizmos

    • 引用位置: 方法调用
    • 关联成员: Gizmos.billboardTextOverBlock(), Gizmos.cuboid()
  • DebugEntityNameGenerator

    • 引用位置: 方法调用
    • 关联成员: DebugEntityNameGenerator.getEntityName()
  • ARGB

    • 引用位置: 方法调用
    • 关联成员: ARGB.colorFromFloat()
  • DebugPoiInfo

    • 引用位置: 参数
  • DebugValueAccess

    • 引用位置: 参数