ComponentArgument.java
net.minecraft.commands.arguments.ComponentArgument
信息
- 全限定名:net.minecraft.commands.arguments.ComponentArgument
- 类型:public class
- 包:net.minecraft.commands.arguments
- 源码路径:src/main/java/net/minecraft/commands/arguments/ComponentArgument.java
- 起始行号:L23
- 继承:ParserBasedArgument
- 职责:
TODO
字段/常量
-
EXAMPLES- 类型:
Collection<String> - 修饰符:
private static final - 源码定位:
L24 - 说明:
TODO
- 类型:
-
ERROR_INVALID_COMPONENT- 类型:
DynamicCommandExceptionType - 修饰符:
public static final - 源码定位:
L25 - 说明:
TODO
- 类型:
-
OPS- 类型:
DynamicOps<Tag> - 修饰符:
private static final - 源码定位:
L28 - 说明:
TODO
- 类型:
-
TAG_PARSER- 类型:
CommandArgumentParser<Tag> - 修饰符:
private static final - 源码定位:
L29 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private ComponentArgument(HolderLookup.Provider registries) @ L31
- 构造器名:ComponentArgument
- 源码定位:L31
- 修饰符:private
参数:
- registries: HolderLookup.Provider
说明:
TODO
方法
下面的方法块按源码顺序生成。
public static Component getRawComponent(CommandContext<CommandSourceStack> context, String name) @ L35
- 方法名:getRawComponent
- 源码定位:L35
- 返回类型:Component
- 修饰符:public static
参数:
- context: CommandContext
- name: String
说明:
TODO
public static Component getResolvedComponent(CommandContext<CommandSourceStack> context, String name, Entity contentEntity) @ L39
- 方法名:getResolvedComponent
- 源码定位:L39
- 返回类型:Component
- 修饰符:public static
参数:
- context: CommandContext
- name: String
- contentEntity: Entity
说明:
TODO
public static Component getResolvedComponent(CommandContext<CommandSourceStack> context, String name) @ L45
- 方法名:getResolvedComponent
- 源码定位:L45
- 返回类型:Component
- 修饰符:public static
参数:
- context: CommandContext
- name: String
说明:
TODO
public static ComponentArgument textComponent(CommandBuildContext context) @ L49
- 方法名:textComponent
- 源码定位:L49
- 返回类型:ComponentArgument
- 修饰符:public static
参数:
- context: CommandBuildContext
说明:
TODO
public Collection<String> getExamples() @ L53
- 方法名:getExamples
- 源码定位:L53
- 返回类型:Collection
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class ComponentArgument extends ParserBasedArgument<Component> {
private static final Collection<String> EXAMPLES = Arrays.asList("\"hello world\"", "'hello world'", "\"\"", "{text:\"hello world\"}", "[\"\"]");
public static final DynamicCommandExceptionType ERROR_INVALID_COMPONENT = new DynamicCommandExceptionType(
message -> Component.translatableEscape("argument.component.invalid", message)
);
private static final DynamicOps<Tag> OPS = NbtOps.INSTANCE;
private static final CommandArgumentParser<Tag> TAG_PARSER = SnbtGrammar.createParser(OPS);
private ComponentArgument(HolderLookup.Provider registries) {
super(TAG_PARSER.withCodec(registries.createSerializationContext(OPS), TAG_PARSER, ComponentSerialization.CODEC, ERROR_INVALID_COMPONENT));
}
public static Component getRawComponent(CommandContext<CommandSourceStack> context, String name) {
return context.getArgument(name, Component.class);
}
public static Component getResolvedComponent(CommandContext<CommandSourceStack> context, String name, Entity contentEntity) throws CommandSyntaxException {
return ComponentUtils.resolve(
ResolutionContext.builder().withSource(context.getSource()).withEntityOverride(contentEntity).build(), getRawComponent(context, name)
);
}
public static Component getResolvedComponent(CommandContext<CommandSourceStack> context, String name) throws CommandSyntaxException {
return ComponentUtils.resolve(ResolutionContext.create(context.getSource()), getRawComponent(context, name));
}
public static ComponentArgument textComponent(CommandBuildContext context) {
return new ComponentArgument(context);
}
@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SnbtGrammar.createParser()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
Component.translatableEscape()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ComponentUtils.resolve()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ResolutionContext.builder(), ResolutionContext.create()
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
继承
- 引用位置:
-
- 引用位置:
参数
- 引用位置: