SelectorContents.java
net.minecraft.network.chat.contents.SelectorContents
信息
- 全限定名:net.minecraft.network.chat.contents.SelectorContents
- 类型:public record
- 包:net.minecraft.network.chat.contents
- 源码路径:src/main/java/net/minecraft/network/chat/contents/SelectorContents.java
- 起始行号:L20
- 实现:ComponentContents
- 职责:
TODO
字段/常量
MAP_CODEC- 类型:
MapCodec<SelectorContents> - 修饰符:
public static final - 源码定位:
L21 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public MapCodec<SelectorContents> codec() @ L29
- 方法名:codec
- 源码定位:L29
- 返回类型:MapCodec
- 修饰符:public
参数:
- 无
说明:
TODO
public MutableComponent resolve(ResolutionContext context, int recursionDepth) @ L34
- 方法名:resolve
- 源码定位:L34
- 返回类型:MutableComponent
- 修饰符:public
参数:
- context: ResolutionContext
- recursionDepth: int
说明:
TODO
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> output, Style currentStyle) @ L45
- 方法名:visit
- 源码定位:L45
- 返回类型:
Optional - 修饰符:public
参数:
- output: FormattedText.StyledContentConsumer
- currentStyle: Style
说明:
TODO
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> output) @ L50
- 方法名:visit
- 源码定位:L50
- 返回类型:
Optional - 修饰符:public
参数:
- output: FormattedText.ContentConsumer
说明:
TODO
public String toString() @ L55
- 方法名:toString
- 源码定位:L55
- 返回类型:String
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public record SelectorContents(CompilableString<EntitySelector> selector, Optional<Component> separator) implements ComponentContents {
public static final MapCodec<SelectorContents> MAP_CODEC = RecordCodecBuilder.mapCodec(
i -> i.group(
EntitySelector.COMPILABLE_CODEC.fieldOf("selector").forGetter(SelectorContents::selector),
ComponentSerialization.CODEC.optionalFieldOf("separator").forGetter(SelectorContents::separator)
)
.apply(i, SelectorContents::new)
);
@Override
public MapCodec<SelectorContents> codec() {
return MAP_CODEC;
}
@Override
public MutableComponent resolve(ResolutionContext context, int recursionDepth) throws CommandSyntaxException {
CommandSourceStack source = context.source();
if (source == null) {
return Component.empty();
} else {
Optional<? extends Component> resolvedSeparator = ComponentUtils.resolve(context, this.separator, recursionDepth);
return ComponentUtils.formatList(this.selector.compiled().findEntities(source), resolvedSeparator, Entity::getDisplayName);
}
}
@Override
public <T> Optional<T> visit(FormattedText.StyledContentConsumer<T> output, Style currentStyle) {
return output.accept(currentStyle, this.selector.source());
}
@Override
public <T> Optional<T> visit(FormattedText.ContentConsumer<T> output) {
return output.accept(this.selector.source());
}
@Override
public String toString() {
return "pattern{" + this.selector + "}";
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
Component.empty()
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ComponentUtils.formatList(), ComponentUtils.resolve()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置: