ArgumentVisitor.java
net.minecraft.commands.ArgumentVisitor
信息
- 全限定名:net.minecraft.commands.ArgumentVisitor
- 类型:public class
- 包:net.minecraft.commands
- 源码路径:src/main/java/net/minecraft/commands/ArgumentVisitor.java
- 起始行号:L11
- 职责:
TODO
字段/常量
- 无
内部类/嵌套类型
net.minecraft.commands.ArgumentVisitor.Output- 类型:
interface - 修饰符:
public - 源码定位:
L42 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static <S> void visitArguments(ParseResults<S> command, ArgumentVisitor.Output<S> output, boolean rejectRootRedirects) @ L12
- 方法名:visitArguments
- 源码定位:L12
- 返回类型:
void - 修饰符:public static
参数:
- command: ParseResults
- output: ArgumentVisitor.Output
- rejectRootRedirects: boolean
说明:
TODO
private static <S> void visitNodeArguments(CommandContextBuilder<S> context, ArgumentVisitor.Output<S> output) @ L24
- 方法名:visitNodeArguments
- 源码定位:L24
- 返回类型:
void - 修饰符:private static
参数:
- context: CommandContextBuilder
- output: ArgumentVisitor.Output
说明:
TODO
private static <S,T> void callVisitor(CommandContextBuilder<S> context, ArgumentVisitor.Output<S> output, ArgumentCommandNode<S,T> argument, ParsedArgument<S,?> value) @ L35
- 方法名:callVisitor
- 源码定位:L35
- 返回类型:<S,T> void
- 修饰符:private static
参数:
- context: CommandContextBuilder
- output: ArgumentVisitor.Output
- argument: ArgumentCommandNode<S,T>
- value: ParsedArgument<S,?>
说明:
TODO
代码
public class ArgumentVisitor {
public static <S> void visitArguments(ParseResults<S> command, ArgumentVisitor.Output<S> output, boolean rejectRootRedirects) {
CommandContextBuilder<S> rootContext = command.getContext();
CommandContextBuilder<S> context = rootContext;
visitNodeArguments(rootContext, output);
CommandContextBuilder<S> child;
while ((child = context.getChild()) != null && (!rejectRootRedirects || child.getRootNode() != rootContext.getRootNode())) {
visitNodeArguments(child, output);
context = child;
}
}
private static <S> void visitNodeArguments(CommandContextBuilder<S> context, ArgumentVisitor.Output<S> output) {
Map<String, ParsedArgument<S, ?>> values = context.getArguments();
for (ParsedCommandNode<S> node : context.getNodes()) {
if (node.getNode() instanceof ArgumentCommandNode<S, ?> argument) {
ParsedArgument<S, ?> value = values.get(argument.getName());
callVisitor(context, output, argument, value);
}
}
}
private static <S, T> void callVisitor(
CommandContextBuilder<S> context, ArgumentVisitor.Output<S> output, ArgumentCommandNode<S, T> argument, @Nullable ParsedArgument<S, ?> value
) {
output.accept(context, argument, (ParsedArgument<S, T>)value);
}
@FunctionalInterface
public interface Output<S> {
<T> void accept(CommandContextBuilder<S> context, ArgumentCommandNode<S, T> argument, final @Nullable ParsedArgument<S, T> value);
}
}引用的其他类
- 无