DebugEntryPosition.java
net.minecraft.client.gui.components.debug.DebugEntryPosition
信息
- 全限定名:net.minecraft.client.gui.components.debug.DebugEntryPosition
- 类型:public class
- 包:net.minecraft.client.gui.components.debug
- 源码路径:src/main/java/net/minecraft/client/gui/components/debug/DebugEntryPosition.java
- 起始行号:L23
- 实现:DebugScreenEntry
- 职责:
TODO
字段/常量
GROUP- 类型:
Identifier - 修饰符:
public static final - 源码定位:
L24 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void display(DebugScreenDisplayer displayer, Level serverOrClientLevel, LevelChunk clientChunk, LevelChunk serverChunk) @ L26
- 方法名:display
- 源码定位:L26
- 返回类型:void
- 修饰符:public
参数:
- displayer: DebugScreenDisplayer
- serverOrClientLevel: Level
- clientChunk: LevelChunk
- serverChunk: LevelChunk
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class DebugEntryPosition implements DebugScreenEntry {
public static final Identifier GROUP = Identifier.withDefaultNamespace("position");
@Override
public void display(DebugScreenDisplayer displayer, @Nullable Level serverOrClientLevel, @Nullable LevelChunk clientChunk, @Nullable LevelChunk serverChunk) {
Minecraft minecraft = Minecraft.getInstance();
Entity entity = minecraft.getCameraEntity();
if (entity != null) {
BlockPos feetPos = minecraft.getCameraEntity().blockPosition();
ChunkPos chunkPos = ChunkPos.containing(feetPos);
Direction direction = entity.getDirection();
String faceString = switch (direction) {
case NORTH -> "Towards negative Z";
case SOUTH -> "Towards positive Z";
case WEST -> "Towards negative X";
case EAST -> "Towards positive X";
default -> "Invalid";
};
LongSet chunks = (LongSet)(serverOrClientLevel instanceof ServerLevel
? ((ServerLevel)serverOrClientLevel).getForceLoadedChunks()
: LongSets.EMPTY_SET);
displayer.addToGroup(
GROUP,
List.of(
String.format(
Locale.ROOT,
"XYZ: %.3f / %.5f / %.3f",
minecraft.getCameraEntity().getX(),
minecraft.getCameraEntity().getY(),
minecraft.getCameraEntity().getZ()
),
String.format(Locale.ROOT, "Block: %d %d %d", feetPos.getX(), feetPos.getY(), feetPos.getZ()),
String.format(
Locale.ROOT,
"Chunk: %d %d %d [%d %d in r.%d.%d.mca]",
chunkPos.x(),
SectionPos.blockToSectionCoord(feetPos.getY()),
chunkPos.z(),
chunkPos.getRegionLocalX(),
chunkPos.getRegionLocalZ(),
chunkPos.getRegionX(),
chunkPos.getRegionZ()
),
String.format(
Locale.ROOT,
"Facing: %s (%s) (%.1f / %.1f)",
direction,
faceString,
Mth.wrapDegrees(entity.getYRot()),
Mth.wrapDegrees(entity.getXRot())
),
minecraft.level.dimension().identifier() + " FC: " + chunks.size()
)
);
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SectionPos.blockToSectionCoord()
- 引用位置:
-
- 引用位置:
字段/方法调用 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Mth.wrapDegrees()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ChunkPos.containing()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: