BeeDebugRenderer.java

net.minecraft.client.renderer.debug.BeeDebugRenderer

信息

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

    TODO

字段/常量

  • SHOW_GOAL_FOR_ALL_BEES

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

      TODO

  • SHOW_NAME_FOR_ALL_BEES

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

      TODO

  • SHOW_HIVE_FOR_ALL_BEES

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

      TODO

  • SHOW_FLOWER_POS_FOR_ALL_BEES

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

      TODO

  • SHOW_TRAVEL_TICKS_FOR_ALL_BEES

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

      TODO

  • SHOW_GOAL_FOR_SELECTED_BEE

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

      TODO

  • SHOW_NAME_FOR_SELECTED_BEE

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

      TODO

  • SHOW_HIVE_FOR_SELECTED_BEE

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

      TODO

  • SHOW_FLOWER_POS_FOR_SELECTED_BEE

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

      TODO

  • SHOW_TRAVEL_TICKS_FOR_SELECTED_BEE

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

      TODO

  • SHOW_HIVE_MEMBERS

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

      TODO

  • SHOW_BLACKLISTS

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

      TODO

  • MAX_RENDER_DIST_FOR_HIVE_OVERLAY

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

      TODO

  • MAX_RENDER_DIST_FOR_BEE_OVERLAY

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

      TODO

  • MAX_TARGETING_DIST

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

      TODO

  • TEXT_SCALE

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

      TODO

  • ORANGE

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

      TODO

  • GRAY

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

      TODO

  • PINK

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

      TODO

  • minecraft

    • 类型: Minecraft
    • 修饰符: private final
    • 源码定位: L52
    • 说明:

      TODO

  • lastLookedAtUuid

    • 类型: UUID
    • 修饰符: private
    • 源码定位: L53
    • 说明:

      TODO

内部类/嵌套类型

构造器

public BeeDebugRenderer(Minecraft minecraft) @ L55

  • 构造器名:BeeDebugRenderer
  • 源码定位:L55
  • 修饰符:public

参数:

  • minecraft: Minecraft

说明:

TODO

方法

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

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

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

参数:

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

说明:

TODO

private void doRender(DebugValueAccess debugValues) @ L67

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

参数:

  • debugValues: DebugValueAccess

说明:

TODO

private Map<BlockPos,Set<UUID>> createHiveBlacklistMap(DebugValueAccess debugValues) @ L91

  • 方法名:createHiveBlacklistMap
  • 源码定位:L91
  • 返回类型:Map<BlockPos,Set>
  • 修饰符:private

参数:

  • debugValues: DebugValueAccess

说明:

TODO

private void renderFlowerInfos(DebugValueAccess debugValues) @ L101

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

参数:

  • debugValues: DebugValueAccess

说明:

TODO

private static String getBeeUuidsAsString(Collection<UUID> uuids) @ L117

  • 方法名:getBeeUuidsAsString
  • 源码定位:L117
  • 返回类型:String
  • 修饰符:private static

参数:

  • uuids: Collection

说明:

TODO

private static void highlightHive(BlockPos hivePos) @ L127

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

参数:

  • hivePos: BlockPos

说明:

TODO

private void renderGhostHive(BlockPos ghostHivePos, List<String> hiveMemberNames) @ L132

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

参数:

  • ghostHivePos: BlockPos
  • hiveMemberNames: List

说明:

TODO

private void renderHiveInfo(BlockPos hivePos, DebugHiveInfo hive, Collection<UUID> beesWhoBlacklistThisHive, DebugValueAccess debugValues) @ L139

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

参数:

  • hivePos: BlockPos
  • hive: DebugHiveInfo
  • beesWhoBlacklistThisHive: Collection
  • debugValues: DebugValueAccess

说明:

TODO

private void renderBeeInfo(Entity entity, DebugBeeInfo beeInfo, DebugGoalInfo goalInfo) @ L158

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

参数:

  • entity: Entity
  • beeInfo: DebugBeeInfo
  • goalInfo: DebugGoalInfo

说明:

TODO

private static void renderTextOverHive(String text, BlockPos hivePos, int row, int color) @ L188

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

参数:

  • text: String
  • hivePos: BlockPos
  • row: int
  • color: int

说明:

TODO

private Camera getCamera() @ L192

  • 方法名:getCamera
  • 源码定位:L192
  • 返回类型:Camera
  • 修饰符:private

参数:

说明:

TODO

private String getPosDescription(Entity entity, BlockPos pos) @ L196

  • 方法名:getPosDescription
  • 源码定位:L196
  • 返回类型:String
  • 修饰符:private

参数:

  • entity: Entity
  • pos: BlockPos

说明:

TODO

private boolean isBeeSelected(Entity entity) @ L202

  • 方法名:isBeeSelected
  • 源码定位:L202
  • 返回类型:boolean
  • 修饰符:private

参数:

  • entity: Entity

说明:

TODO

private Collection<UUID> getHiveMembers(BlockPos hivePos, DebugValueAccess debugValues) @ L206

  • 方法名:getHiveMembers
  • 源码定位:L206
  • 返回类型:Collection
  • 修饰符:private

参数:

  • hivePos: BlockPos
  • debugValues: DebugValueAccess

说明:

TODO

private Map<BlockPos,List<String>> getGhostHives(DebugValueAccess debugValues) @ L216

  • 方法名:getGhostHives
  • 源码定位:L216
  • 返回类型:Map<BlockPos,List>
  • 修饰符:private

参数:

  • debugValues: DebugValueAccess

说明:

TODO

private void updateLastLookedAtUuid() @ L226

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

参数:

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class BeeDebugRenderer implements DebugRenderer.SimpleDebugRenderer {
    private static final boolean SHOW_GOAL_FOR_ALL_BEES = true;
    private static final boolean SHOW_NAME_FOR_ALL_BEES = true;
    private static final boolean SHOW_HIVE_FOR_ALL_BEES = true;
    private static final boolean SHOW_FLOWER_POS_FOR_ALL_BEES = true;
    private static final boolean SHOW_TRAVEL_TICKS_FOR_ALL_BEES = true;
    private static final boolean SHOW_GOAL_FOR_SELECTED_BEE = true;
    private static final boolean SHOW_NAME_FOR_SELECTED_BEE = true;
    private static final boolean SHOW_HIVE_FOR_SELECTED_BEE = true;
    private static final boolean SHOW_FLOWER_POS_FOR_SELECTED_BEE = true;
    private static final boolean SHOW_TRAVEL_TICKS_FOR_SELECTED_BEE = true;
    private static final boolean SHOW_HIVE_MEMBERS = true;
    private static final boolean SHOW_BLACKLISTS = true;
    private static final int MAX_RENDER_DIST_FOR_HIVE_OVERLAY = 30;
    private static final int MAX_RENDER_DIST_FOR_BEE_OVERLAY = 30;
    private static final int MAX_TARGETING_DIST = 8;
    private static final float TEXT_SCALE = 0.32F;
    private static final int ORANGE = -23296;
    private static final int GRAY = -3355444;
    private static final int PINK = -98404;
    private final Minecraft minecraft;
    private @Nullable UUID lastLookedAtUuid;
 
    public BeeDebugRenderer(Minecraft minecraft) {
        this.minecraft = minecraft;
    }
 
    @Override
    public void emitGizmos(double camX, double camY, double camZ, DebugValueAccess debugValues, Frustum frustum, float partialTicks) {
        this.doRender(debugValues);
        if (!this.minecraft.player.isSpectator()) {
            this.updateLastLookedAtUuid();
        }
    }
 
    private void doRender(DebugValueAccess debugValues) {
        BlockPos playerPos = this.getCamera().blockPosition();
        debugValues.forEachEntity(DebugSubscriptions.BEES, (entity, beeInfo) -> {
            if (this.minecraft.player.closerThan(entity, 30.0)) {
                DebugGoalInfo goalInfo = debugValues.getEntityValue(DebugSubscriptions.GOAL_SELECTORS, entity);
                this.renderBeeInfo(entity, beeInfo, goalInfo);
            }
        });
        this.renderFlowerInfos(debugValues);
        Map<BlockPos, Set<UUID>> hiveBlacklistMap = this.createHiveBlacklistMap(debugValues);
        debugValues.forEachBlock(DebugSubscriptions.BEE_HIVES, (pos, hive) -> {
            if (playerPos.closerThan(pos, 30.0)) {
                highlightHive(pos);
                Set<UUID> beesWhoBlacklistThisHive = hiveBlacklistMap.getOrDefault(pos, Set.of());
                this.renderHiveInfo(pos, hive, beesWhoBlacklistThisHive, debugValues);
            }
        });
        this.getGhostHives(debugValues).forEach((ghostHivePos, value) -> {
            if (playerPos.closerThan(ghostHivePos, 30.0)) {
                this.renderGhostHive(ghostHivePos, (List<String>)value);
            }
        });
    }
 
    private Map<BlockPos, Set<UUID>> createHiveBlacklistMap(DebugValueAccess debugValues) {
        Map<BlockPos, Set<UUID>> hiveBlacklistMap = new HashMap<>();
        debugValues.forEachEntity(DebugSubscriptions.BEES, (entity, bee) -> {
            for (BlockPos blacklistedFlowerPos : bee.blacklistedHives()) {
                hiveBlacklistMap.computeIfAbsent(blacklistedFlowerPos, k -> new HashSet<>()).add(entity.getUUID());
            }
        });
        return hiveBlacklistMap;
    }
 
    private void renderFlowerInfos(DebugValueAccess debugValues) {
        Map<BlockPos, Set<UUID>> beesPerFlower = new HashMap<>();
        debugValues.forEachEntity(DebugSubscriptions.BEES, (entity, bee) -> {
            if (bee.flowerPos().isPresent()) {
                beesPerFlower.computeIfAbsent(bee.flowerPos().get(), k -> new HashSet<>()).add(entity.getUUID());
            }
        });
        beesPerFlower.forEach((flowerPos, beesWithThisFlower) -> {
            Set<String> beeNames = beesWithThisFlower.stream().map(DebugEntityNameGenerator::getEntityName).collect(Collectors.toSet());
            int row = 1;
            Gizmos.billboardTextOverBlock(beeNames.toString(), flowerPos, row++, -256, 0.32F);
            Gizmos.billboardTextOverBlock("Flower", flowerPos, row++, -1, 0.32F);
            Gizmos.cuboid(flowerPos, 0.05F, GizmoStyle.fill(ARGB.colorFromFloat(0.3F, 0.8F, 0.8F, 0.0F)));
        });
    }
 
    private static String getBeeUuidsAsString(Collection<UUID> uuids) {
        if (uuids.isEmpty()) {
            return "-";
        } else {
            return uuids.size() > 3
                ? uuids.size() + " bees"
                : uuids.stream().map(DebugEntityNameGenerator::getEntityName).collect(Collectors.toSet()).toString();
        }
    }
 
    private static void highlightHive(BlockPos hivePos) {
        float padding = 0.05F;
        Gizmos.cuboid(hivePos, 0.05F, GizmoStyle.fill(ARGB.colorFromFloat(0.3F, 0.2F, 0.2F, 1.0F)));
    }
 
    private void renderGhostHive(BlockPos ghostHivePos, List<String> hiveMemberNames) {
        float padding = 0.05F;
        Gizmos.cuboid(ghostHivePos, 0.05F, GizmoStyle.fill(ARGB.colorFromFloat(0.3F, 0.2F, 0.2F, 1.0F)));
        Gizmos.billboardTextOverBlock(hiveMemberNames.toString(), ghostHivePos, 0, -256, 0.32F);
        Gizmos.billboardTextOverBlock("Ghost Hive", ghostHivePos, 1, -65536, 0.32F);
    }
 
    private void renderHiveInfo(BlockPos hivePos, DebugHiveInfo hive, Collection<UUID> beesWhoBlacklistThisHive, DebugValueAccess debugValues) {
        int row = 0;
        if (!beesWhoBlacklistThisHive.isEmpty()) {
            renderTextOverHive("Blacklisted by " + getBeeUuidsAsString(beesWhoBlacklistThisHive), hivePos, row++, -65536);
        }
 
        renderTextOverHive("Out: " + getBeeUuidsAsString(this.getHiveMembers(hivePos, debugValues)), hivePos, row++, -3355444);
        if (hive.occupantCount() == 0) {
            renderTextOverHive("In: -", hivePos, row++, -256);
        } else if (hive.occupantCount() == 1) {
            renderTextOverHive("In: 1 bee", hivePos, row++, -256);
        } else {
            renderTextOverHive("In: " + hive.occupantCount() + " bees", hivePos, row++, -256);
        }
 
        renderTextOverHive("Honey: " + hive.honeyLevel(), hivePos, row++, -23296);
        renderTextOverHive(hive.type().getName().getString() + (hive.sedated() ? " (sedated)" : ""), hivePos, row++, -1);
    }
 
    private void renderBeeInfo(Entity entity, DebugBeeInfo beeInfo, @Nullable DebugGoalInfo goalInfo) {
        boolean selected = this.isBeeSelected(entity);
        int row = 0;
        Gizmos.billboardTextOverMob(entity, row++, beeInfo.toString(), -1, 0.48F);
        if (beeInfo.hivePos().isEmpty()) {
            Gizmos.billboardTextOverMob(entity, row++, "No hive", -98404, 0.32F);
        } else {
            Gizmos.billboardTextOverMob(entity, row++, "Hive: " + this.getPosDescription(entity, beeInfo.hivePos().get()), -256, 0.32F);
        }
 
        if (beeInfo.flowerPos().isEmpty()) {
            Gizmos.billboardTextOverMob(entity, row++, "No flower", -98404, 0.32F);
        } else {
            Gizmos.billboardTextOverMob(entity, row++, "Flower: " + this.getPosDescription(entity, beeInfo.flowerPos().get()), -256, 0.32F);
        }
 
        if (goalInfo != null) {
            for (DebugGoalInfo.DebugGoal goal : goalInfo.goals()) {
                if (goal.isRunning()) {
                    Gizmos.billboardTextOverMob(entity, row++, goal.name(), -16711936, 0.32F);
                }
            }
        }
 
        if (beeInfo.travelTicks() > 0) {
            int color = beeInfo.travelTicks() < 2400 ? -3355444 : -23296;
            Gizmos.billboardTextOverMob(entity, row++, "Travelling: " + beeInfo.travelTicks() + " ticks", color, 0.32F);
        }
    }
 
    private static void renderTextOverHive(String text, BlockPos hivePos, int row, int color) {
        Gizmos.billboardTextOverBlock(text, hivePos, row, color, 0.32F);
    }
 
    private Camera getCamera() {
        return this.minecraft.gameRenderer.getMainCamera();
    }
 
    private String getPosDescription(Entity entity, BlockPos pos) {
        double dist = pos.distToCenterSqr(entity.position());
        double distRounded = Math.round(dist * 10.0) / 10.0;
        return pos.toShortString() + " (dist " + distRounded + ")";
    }
 
    private boolean isBeeSelected(Entity entity) {
        return Objects.equals(this.lastLookedAtUuid, entity.getUUID());
    }
 
    private Collection<UUID> getHiveMembers(BlockPos hivePos, DebugValueAccess debugValues) {
        Set<UUID> hiveMembers = new HashSet<>();
        debugValues.forEachEntity(DebugSubscriptions.BEES, (entity, beeInfo) -> {
            if (beeInfo.hasHive(hivePos)) {
                hiveMembers.add(entity.getUUID());
            }
        });
        return hiveMembers;
    }
 
    private Map<BlockPos, List<String>> getGhostHives(DebugValueAccess debugValues) {
        Map<BlockPos, List<String>> ghostHives = new HashMap<>();
        debugValues.forEachEntity(DebugSubscriptions.BEES, (entity, beeInfo) -> {
            if (beeInfo.hivePos().isPresent() && debugValues.getBlockValue(DebugSubscriptions.BEE_HIVES, beeInfo.hivePos().get()) == null) {
                ghostHives.computeIfAbsent(beeInfo.hivePos().get(), k -> Lists.newArrayList()).add(DebugEntityNameGenerator.getEntityName(entity));
            }
        });
        return ghostHives;
    }
 
    private void updateLastLookedAtUuid() {
        DebugRenderer.getTargetedEntity(this.minecraft.getCameraEntity(), 8).ifPresent(entity -> this.lastLookedAtUuid = entity.getUUID());
    }
}

引用的其他类

  • Camera

    • 引用位置: 返回值
  • Minecraft

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

    • 引用位置: 参数
  • DebugRenderer

    • 引用位置: 实现/方法调用
    • 关联成员: DebugRenderer.getTargetedEntity()
  • BlockPos

    • 引用位置: 参数/返回值
  • GizmoStyle

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

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

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

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

    • 引用位置: 参数
  • DebugGoalInfo

    • 引用位置: 参数
  • DebugHiveInfo

    • 引用位置: 参数
  • DebugValueAccess

    • 引用位置: 参数
  • Entity

    • 引用位置: 参数