StorageDataAccessor.java
net.minecraft.server.commands.data.StorageDataAccessor
信息
- 全限定名:net.minecraft.server.commands.data.StorageDataAccessor
- 类型:public class
- 包:net.minecraft.server.commands.data
- 源码路径:src/main/java/net/minecraft/server/commands/data/StorageDataAccessor.java
- 起始行号:L20
- 实现:DataAccessor
- 职责:
TODO
字段/常量
-
SUGGEST_STORAGE- 类型:
SuggestionProvider<CommandSourceStack> - 修饰符:
private static final - 源码定位:
L21 - 说明:
TODO
- 类型:
-
PROVIDER- 类型:
Function<String,DataCommands.DataProvider> - 修饰符:
public static final public public - 源码定位:
L22 - 说明:
TODO
- 类型:
-
storage- 类型:
CommandStorage - 修饰符:
private final - 源码定位:
L37 - 说明:
TODO
- 类型:
-
id- 类型:
Identifier - 修饰符:
private final - 源码定位:
L38 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
private StorageDataAccessor(CommandStorage storage, Identifier id) @ L44
- 构造器名:StorageDataAccessor
- 源码定位:L44
- 修饰符:private
参数:
- storage: CommandStorage
- id: Identifier
说明:
TODO
方法
下面的方法块按源码顺序生成。
private static CommandStorage getGlobalTags(CommandContext<CommandSourceStack> context) @ L40
- 方法名:getGlobalTags
- 源码定位:L40
- 返回类型:CommandStorage
- 修饰符:private static
参数:
- context: CommandContext
说明:
TODO
public void setData(CompoundTag tag) @ L49
- 方法名:setData
- 源码定位:L49
- 返回类型:void
- 修饰符:public
参数:
- tag: CompoundTag
说明:
TODO
public CompoundTag getData() @ L54
- 方法名:getData
- 源码定位:L54
- 返回类型:CompoundTag
- 修饰符:public
参数:
- 无
说明:
TODO
public Component getModifiedSuccess() @ L59
- 方法名:getModifiedSuccess
- 源码定位:L59
- 返回类型:Component
- 修饰符:public
参数:
- 无
说明:
TODO
public Component getPrintSuccess(Tag data) @ L64
- 方法名:getPrintSuccess
- 源码定位:L64
- 返回类型:Component
- 修饰符:public
参数:
- data: Tag
说明:
TODO
public Component getPrintSuccess(NbtPathArgument.NbtPath path, double scale, int value) @ L69
- 方法名:getPrintSuccess
- 源码定位:L69
- 返回类型:Component
- 修饰符:public
参数:
- path: NbtPathArgument.NbtPath
- scale: double
- value: int
说明:
TODO
代码
public class StorageDataAccessor implements DataAccessor {
private static final SuggestionProvider<CommandSourceStack> SUGGEST_STORAGE = (c, p) -> SharedSuggestionProvider.suggestResource(getGlobalTags(c).keys(), p);
public static final Function<String, DataCommands.DataProvider> PROVIDER = arg -> new DataCommands.DataProvider() {
@Override
public DataAccessor access(CommandContext<CommandSourceStack> context) {
return new StorageDataAccessor(StorageDataAccessor.getGlobalTags(context), IdentifierArgument.getId(context, arg));
}
@Override
public ArgumentBuilder<CommandSourceStack, ?> wrap(
ArgumentBuilder<CommandSourceStack, ?> parent, Function<ArgumentBuilder<CommandSourceStack, ?>, ArgumentBuilder<CommandSourceStack, ?>> function
) {
return parent.then(
Commands.literal("storage").then(function.apply(Commands.argument(arg, IdentifierArgument.id()).suggests(StorageDataAccessor.SUGGEST_STORAGE)))
);
}
};
private final CommandStorage storage;
private final Identifier id;
private static CommandStorage getGlobalTags(CommandContext<CommandSourceStack> context) {
return context.getSource().getServer().getCommandStorage();
}
private StorageDataAccessor(CommandStorage storage, Identifier id) {
this.storage = storage;
this.id = id;
}
@Override
public void setData(CompoundTag tag) {
this.storage.set(this.id, tag);
}
@Override
public CompoundTag getData() {
return this.storage.get(this.id);
}
@Override
public Component getModifiedSuccess() {
return Component.translatable("commands.data.storage.modified", Component.translationArg(this.id));
}
@Override
public Component getPrintSuccess(Tag data) {
return Component.translatable("commands.data.storage.query", Component.translationArg(this.id), NbtUtils.toPrettyComponent(data));
}
@Override
public Component getPrintSuccess(NbtPathArgument.NbtPath path, double scale, int value) {
return Component.translatable(
"commands.data.storage.get", path.asString(), Component.translationArg(this.id), String.format(Locale.ROOT, "%.2f", scale), value
);
}
}引用的其他类
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Commands.argument(), Commands.literal()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
SharedSuggestionProvider.suggestResource()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
IdentifierArgument.getId(), IdentifierArgument.id()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数/返回值
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
NbtUtils.toPrettyComponent()
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用/返回值 - 关联成员:
Component.translatable(), Component.translationArg()
- 引用位置:
-
- 引用位置:
参数/字段
- 引用位置:
-
- 引用位置:
实现
- 引用位置:
-
- 引用位置:
字段/方法调用/构造调用 - 关联成员:
DataCommands.DataProvider(), DataProvider()
- 引用位置:
-
- 引用位置:
参数/字段/返回值
- 引用位置: