FunctionBuilder.java
net.minecraft.commands.functions.FunctionBuilder
信息
- 全限定名:net.minecraft.commands.functions.FunctionBuilder
- 类型:package-private class
- 包:net.minecraft.commands.functions
- 源码路径:src/main/java/net/minecraft/commands/functions/FunctionBuilder.java
- 起始行号:L12
- 职责:
TODO
字段/常量
-
plainEntries- 类型:
List<UnboundEntryAction<T>> - 修饰符:
private - 源码定位:
L13 - 说明:
TODO
- 类型:
-
macroEntries- 类型:
List<MacroFunction.Entry<T>> - 修饰符:
private - 源码定位:
L14 - 说明:
TODO
- 类型:
-
macroArguments- 类型:
List<String> - 修饰符:
private final - 源码定位:
L15 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public void addCommand(UnboundEntryAction<T> command) @ L17
- 方法名:addCommand
- 源码定位:L17
- 返回类型:void
- 修饰符:public
参数:
- command: UnboundEntryAction
说明:
TODO
private int getArgumentIndex(String id) @ L25
- 方法名:getArgumentIndex
- 源码定位:L25
- 返回类型:int
- 修饰符:private
参数:
- id: String
说明:
TODO
private IntList convertToIndices(List<String> ids) @ L35
- 方法名:convertToIndices
- 源码定位:L35
- 返回类型:IntList
- 修饰符:private
参数:
- ids: List
说明:
TODO
public void addMacro(String command, int line, T compilationContext) @ L45
- 方法名:addMacro
- 源码定位:L45
- 返回类型:void
- 修饰符:public
参数:
- command: String
- line: int
- compilationContext: T
说明:
TODO
public CommandFunction<T> build(Identifier id) @ L66
- 方法名:build
- 源码定位:L66
- 返回类型:CommandFunction
- 修饰符:public
参数:
- id: Identifier
说明:
TODO
代码
class FunctionBuilder<T extends ExecutionCommandSource<T>> {
private @Nullable List<UnboundEntryAction<T>> plainEntries = new ArrayList<>();
private @Nullable List<MacroFunction.Entry<T>> macroEntries;
private final List<String> macroArguments = new ArrayList<>();
public void addCommand(UnboundEntryAction<T> command) {
if (this.macroEntries != null) {
this.macroEntries.add(new MacroFunction.PlainTextEntry<>(command));
} else {
this.plainEntries.add(command);
}
}
private int getArgumentIndex(String id) {
int index = this.macroArguments.indexOf(id);
if (index == -1) {
index = this.macroArguments.size();
this.macroArguments.add(id);
}
return index;
}
private IntList convertToIndices(List<String> ids) {
IntArrayList result = new IntArrayList(ids.size());
for (String id : ids) {
result.add(this.getArgumentIndex(id));
}
return result;
}
public void addMacro(String command, int line, T compilationContext) {
StringTemplate parseResults;
try {
parseResults = StringTemplate.fromString(command);
} catch (Exception var7) {
throw new IllegalArgumentException("Can't parse function line " + line + ": '" + command + "'", var7);
}
if (this.plainEntries != null) {
this.macroEntries = new ArrayList<>(this.plainEntries.size() + 1);
for (UnboundEntryAction<T> plainEntry : this.plainEntries) {
this.macroEntries.add(new MacroFunction.PlainTextEntry<>(plainEntry));
}
this.plainEntries = null;
}
this.macroEntries.add(new MacroFunction.MacroEntry<>(parseResults, this.convertToIndices(parseResults.variables()), compilationContext));
}
public CommandFunction<T> build(Identifier id) {
return (CommandFunction<T>)(this.macroEntries != null
? new MacroFunction<>(id, this.macroEntries, this.macroArguments)
: new PlainTextFunction<>(id, this.plainEntries));
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
返回值
- 引用位置:
-
- 引用位置:
字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
StringTemplate.fromString()
- 引用位置:
-
- 引用位置:
参数
- 引用位置: