SlotsArgument.java
net.minecraft.commands.arguments.SlotsArgument
信息
- 全限定名:net.minecraft.commands.arguments.SlotsArgument
- 类型:public class
- 包:net.minecraft.commands.arguments
- 源码路径:src/main/java/net/minecraft/commands/arguments/SlotsArgument.java
- 起始行号:L20
- 实现:ArgumentType
- 职责:
TODO
字段/常量
-
EXAMPLES- 类型:
Collection<String> - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
ERROR_UNKNOWN_SLOT- 类型:
DynamicCommandExceptionType - 修饰符:
private static final - 源码定位:
L22 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
- 无
方法
下面的方法块按源码顺序生成。
public static SlotsArgument slots() @ L26
- 方法名:slots
- 源码定位:L26
- 返回类型:SlotsArgument
- 修饰符:public static
参数:
- 无
说明:
TODO
public static SlotRange getSlots(CommandContext<CommandSourceStack> context, String name) @ L30
- 方法名:getSlots
- 源码定位:L30
- 返回类型:SlotRange
- 修饰符:public static
参数:
- context: CommandContext
- name: String
说明:
TODO
public SlotRange parse(StringReader reader) @ L34
- 方法名:parse
- 源码定位:L34
- 返回类型:SlotRange
- 修饰符:public
参数:
- reader: StringReader
说明:
TODO
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> contextBuilder, SuggestionsBuilder builder) @ L44
- 方法名:listSuggestions
- 源码定位:L44
- 返回类型:
CompletableFuture - 修饰符:public
参数:
- contextBuilder: CommandContext
- builder: SuggestionsBuilder
说明:
TODO
public Collection<String> getExamples() @ L49
- 方法名:getExamples
- 源码定位:L49
- 返回类型:Collection
- 修饰符:public
参数:
- 无
说明:
TODO
代码
public class SlotsArgument implements ArgumentType<SlotRange> {
private static final Collection<String> EXAMPLES = List.of("container.*", "container.5", "weapon");
private static final DynamicCommandExceptionType ERROR_UNKNOWN_SLOT = new DynamicCommandExceptionType(
id -> Component.translatableEscape("slot.unknown", id)
);
public static SlotsArgument slots() {
return new SlotsArgument();
}
public static SlotRange getSlots(CommandContext<CommandSourceStack> context, String name) {
return context.getArgument(name, SlotRange.class);
}
public SlotRange parse(StringReader reader) throws CommandSyntaxException {
String name = ParserUtils.readWhile(reader, c -> c != ' ');
SlotRange result = SlotRanges.nameToIds(name);
if (result == null) {
throw ERROR_UNKNOWN_SLOT.createWithContext(reader, name);
} else {
return result;
}
}
@Override
public <S> CompletableFuture<Suggestions> listSuggestions(CommandContext<S> contextBuilder, SuggestionsBuilder builder) {
return SharedSuggestionProvider.suggest(SlotRanges.allNames(), builder);
}
@Override
public Collection<String> getExamples() {
return EXAMPLES;
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
ParserUtils.readWhile()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedSuggestionProvider.suggest()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Component.translatableEscape()
- 引用位置:
-
- 引用位置:
实现/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SlotRanges.allNames(), SlotRanges.nameToIds()
- 引用位置: