DebugEntryLookingAt.java
net.minecraft.client.gui.components.debug.DebugEntryLookingAt
信息
- 全限定名:net.minecraft.client.gui.components.debug.DebugEntryLookingAt
- 类型:public abstract class
- 包:net.minecraft.client.gui.components.debug
- 源码路径:src/main/java/net/minecraft/client/gui/components/debug/DebugEntryLookingAt.java
- 起始行号:L27
- 实现:DebugScreenEntry
- 职责:
TODO
字段/常量
-
RANGE- 类型:
int - 修饰符:
private static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
BLOCK_GROUP- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
-
FLUID_GROUP- 类型:
Identifier - 修饰符:
private static final - 源码定位:
L30 - 说明:
TODO
- 类型:
内部类/嵌套类型
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.BlockStateInfo- 类型:
class - 修饰符:
public static - 源码定位:
L59 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.BlockTagInfo- 类型:
class - 修饰符:
public static - 源码定位:
L80 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.DebugEntryLookingAtState- 类型:
class - 修饰符:
public abstract static - 源码定位:
L97 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.DebugEntryLookingAtTags- 类型:
class - 修饰符:
public abstract static - 源码定位:
L132 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.FluidStateInfo- 类型:
class - 修饰符:
public static - 源码定位:
L143 - 说明:
TODO
- 类型:
-
net.minecraft.client.gui.components.debug.DebugEntryLookingAt.FluidTagInfo- 类型:
class - 修饰符:
public static - 源码定位:
L164 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void display(DebugScreenDisplayer displayer, Level serverOrClientLevel, LevelChunk clientChunk, LevelChunk serverChunk) @ L32
- 方法名:display
- 源码定位:L32
- 返回类型:void
- 修饰符:public
参数:
- displayer: DebugScreenDisplayer
- serverOrClientLevel: Level
- clientChunk: LevelChunk
- serverChunk: LevelChunk
说明:
TODO
public abstract HitResult getHitResult(Entity cameraEntity) @ L48
- 方法名:getHitResult
- 源码定位:L48
- 返回类型:HitResult
- 修饰符:public abstract
参数:
- cameraEntity: Entity
说明:
TODO
public abstract void extractInfo(List<String> result, Level level, BlockPos pos) @ L50
- 方法名:extractInfo
- 源码定位:L50
- 返回类型:void
- 修饰符:public abstract
参数:
- result: List
- level: Level
- pos: BlockPos
说明:
TODO
public abstract Identifier group() @ L52
- 方法名:group
- 源码定位:L52
- 返回类型:Identifier
- 修饰符:public abstract
参数:
- 无
说明:
TODO
public static void addTagEntries(List<String> result, TypedInstance<?> instance) @ L54
- 方法名:addTagEntries
- 源码定位:L54
- 返回类型:void
- 修饰符:public static
参数:
- result: List
- instance: TypedInstance<?>
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public abstract class DebugEntryLookingAt implements DebugScreenEntry {
private static final int RANGE = 20;
private static final Identifier BLOCK_GROUP = Identifier.withDefaultNamespace("looking_at_block");
private static final Identifier FLUID_GROUP = Identifier.withDefaultNamespace("looking_at_fluid");
@Override
public void display(DebugScreenDisplayer displayer, @Nullable Level serverOrClientLevel, @Nullable LevelChunk clientChunk, @Nullable LevelChunk serverChunk) {
Entity cameraEntity = Minecraft.getInstance().getCameraEntity();
Level clientOrServerLevel = (Level)(SharedConstants.DEBUG_SHOW_SERVER_DEBUG_VALUES ? serverOrClientLevel : Minecraft.getInstance().level);
if (cameraEntity != null && clientOrServerLevel != null) {
HitResult block = this.getHitResult(cameraEntity);
List<String> result = new ArrayList<>();
if (block.getType() == HitResult.Type.BLOCK) {
BlockPos pos = ((BlockHitResult)block).getBlockPos();
this.extractInfo(result, clientOrServerLevel, pos);
}
displayer.addToGroup(this.group(), result);
}
}
public abstract HitResult getHitResult(final Entity cameraEntity);
public abstract void extractInfo(List<String> result, Level level, BlockPos pos);
public abstract Identifier group();
public static void addTagEntries(List<String> result, TypedInstance<?> instance) {
instance.tags().map(e -> "#" + e.location()).forEach(result::add);
}
@OnlyIn(Dist.CLIENT)
public static class BlockStateInfo extends DebugEntryLookingAt.DebugEntryLookingAtState<Block, BlockState> {
protected BlockStateInfo() {
super("Targeted Block");
}
@Override
public HitResult getHitResult(Entity cameraEntity) {
return cameraEntity.pick(20.0, 0.0F, false);
}
public BlockState getInstance(Level level, BlockPos pos) {
return level.getBlockState(pos);
}
@Override
public Identifier group() {
return DebugEntryLookingAt.BLOCK_GROUP;
}
}
@OnlyIn(Dist.CLIENT)
public static class BlockTagInfo extends DebugEntryLookingAt.DebugEntryLookingAtTags<BlockState> {
@Override
public HitResult getHitResult(Entity cameraEntity) {
return cameraEntity.pick(20.0, 0.0F, false);
}
public BlockState getInstance(Level level, BlockPos pos) {
return level.getBlockState(pos);
}
@Override
public Identifier group() {
return DebugEntryLookingAt.BLOCK_GROUP;
}
}
@OnlyIn(Dist.CLIENT)
public abstract static class DebugEntryLookingAtState<OwnerType, StateType extends StateHolder<OwnerType, StateType> & TypedInstance<OwnerType>>
extends DebugEntryLookingAt {
private final String prefix;
protected DebugEntryLookingAtState(String prefix) {
this.prefix = prefix;
}
protected abstract StateType getInstance(Level level, BlockPos pos);
@Override
public void extractInfo(List<String> result, Level level, BlockPos pos) {
StateType stateInstance = this.getInstance(level, pos);
result.add(ChatFormatting.UNDERLINE + this.prefix + ": " + pos.getX() + ", " + pos.getY() + ", " + pos.getZ());
result.add(stateInstance.typeHolder().getRegisteredName());
addStateProperties(result, stateInstance);
}
private static void addStateProperties(List<String> result, StateHolder<?, ?> stateHolder) {
stateHolder.getValues().forEach(entry -> result.add(getPropertyValueString((Property.Value<?>)entry)));
}
private static String getPropertyValueString(Property.Value<?> entry) {
String valueString = entry.valueName();
if (Boolean.TRUE.equals(entry.value())) {
valueString = ChatFormatting.GREEN + valueString;
} else if (Boolean.FALSE.equals(entry.value())) {
valueString = ChatFormatting.RED + valueString;
}
return entry.property().getName() + ": " + valueString;
}
}
@OnlyIn(Dist.CLIENT)
public abstract static class DebugEntryLookingAtTags<T extends TypedInstance<?>> extends DebugEntryLookingAt {
protected abstract T getInstance(Level level, BlockPos pos);
@Override
public void extractInfo(List<String> result, Level level, BlockPos pos) {
T instance = this.getInstance(level, pos);
addTagEntries(result, instance);
}
}
@OnlyIn(Dist.CLIENT)
public static class FluidStateInfo extends DebugEntryLookingAt.DebugEntryLookingAtState<Fluid, FluidState> {
protected FluidStateInfo() {
super("Targeted Fluid");
}
@Override
public HitResult getHitResult(Entity cameraEntity) {
return cameraEntity.pick(20.0, 0.0F, true);
}
public FluidState getInstance(Level level, BlockPos pos) {
return level.getFluidState(pos);
}
@Override
public Identifier group() {
return DebugEntryLookingAt.FLUID_GROUP;
}
}
@OnlyIn(Dist.CLIENT)
public static class FluidTagInfo extends DebugEntryLookingAt.DebugEntryLookingAtTags<FluidState> {
@Override
public HitResult getHitResult(Entity cameraEntity) {
return cameraEntity.pick(20.0, 0.0F, true);
}
public FluidState getInstance(Level level, BlockPos pos) {
return level.getFluidState(pos);
}
@Override
public Identifier group() {
return DebugEntryLookingAt.FLUID_GROUP;
}
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
字段/方法调用/返回值 - 关联成员:
Identifier.withDefaultNamespace()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置: