DataProvider.java
net.minecraft.data.DataProvider
信息
- 全限定名:net.minecraft.data.DataProvider
- 类型:public interface
- 包:net.minecraft.data
- 源码路径:src/main/java/net/minecraft/data/DataProvider.java
- 起始行号:L29
- 职责:
TODO
字段/常量
-
FIXED_ORDER_FIELDS- 类型:
ToIntFunction<String> - 修饰符:
package-private - 源码定位:
L30 - 说明:
TODO
- 类型:
-
KEY_COMPARATOR- 类型:
Comparator<String> - 修饰符:
package-private - 源码定位:
L35 - 说明:
TODO
- 类型:
-
LOGGER- 类型:
Logger - 修饰符:
package-private - 源码定位:
L36 - 说明:
TODO
- 类型:
内部类/嵌套类型
net.minecraft.data.DataProvider.Factory- 类型:
interface - 修饰符:
public - 源码定位:
L92 - 说明:
TODO
- 类型:
构造器
- 无
方法
下面的方法块按源码顺序生成。
CompletableFuture<?> run(CachedOutput cache) @ L38
- 方法名:run
- 源码定位:L38
- 返回类型:CompletableFuture<?>
- 修饰符:package-private
参数:
- cache: CachedOutput
说明:
TODO
String getName() @ L40
- 方法名:getName
- 源码定位:L40
- 返回类型:String
- 修饰符:package-private
参数:
- 无
说明:
TODO
static <T> CompletableFuture<?> saveAll(CachedOutput cache, Codec<T> codec, PackOutput.PathProvider pathProvider, Map<Identifier,T> entries) @ L42
- 方法名:saveAll
- 源码定位:L42
- 返回类型:
CompletableFuture<?> - 修饰符:static
参数:
- cache: CachedOutput
- codec: Codec
- pathProvider: PackOutput.PathProvider
- entries: Map<Identifier,T>
说明:
TODO
static <T,E> CompletableFuture<?> saveAll(CachedOutput cache, Codec<E> codec, Function<T,Path> pathGetter, Map<T,E> contents) @ L46
- 方法名:saveAll
- 源码定位:L46
- 返回类型:<T,E> CompletableFuture<?>
- 修饰符:static
参数:
- cache: CachedOutput
- codec: Codec
- pathGetter: Function<T,Path>
- contents: Map<T,E>
说明:
TODO
static <T,E> CompletableFuture<?> saveAll(CachedOutput cache, Function<E,JsonElement> serializer, Function<T,Path> pathGetter, Map<T,E> contents) @ L50
- 方法名:saveAll
- 源码定位:L50
- 返回类型:<T,E> CompletableFuture<?>
- 修饰符:static
参数:
- cache: CachedOutput
- serializer: Function<E,JsonElement>
- pathGetter: Function<T,Path>
- contents: Map<T,E>
说明:
TODO
static <T> CompletableFuture<?> saveStable(CachedOutput cache, HolderLookup.Provider registries, Codec<T> codec, T value, Path path) @ L58
- 方法名:saveStable
- 源码定位:L58
- 返回类型:
CompletableFuture<?> - 修饰符:static
参数:
- cache: CachedOutput
- registries: HolderLookup.Provider
- codec: Codec
- value: T
- path: Path
说明:
TODO
static <T> CompletableFuture<?> saveStable(CachedOutput cache, Codec<T> codec, T value, Path path) @ L63
- 方法名:saveStable
- 源码定位:L63
- 返回类型:
CompletableFuture<?> - 修饰符:static
参数:
- cache: CachedOutput
- codec: Codec
- value: T
- path: Path
说明:
TODO
private static <T> CompletableFuture<?> saveStable(CachedOutput cache, DynamicOps<JsonElement> ops, Codec<T> codec, T value, Path path) @ L67
- 方法名:saveStable
- 源码定位:L67
- 返回类型:
CompletableFuture<?> - 修饰符:private static
参数:
- cache: CachedOutput
- ops: DynamicOps
- codec: Codec
- value: T
- path: Path
说明:
TODO
static CompletableFuture<?> saveStable(CachedOutput cache, JsonElement root, Path path) @ L72
- 方法名:saveStable
- 源码定位:L72
- 返回类型:CompletableFuture<?>
- 修饰符:static
参数:
- cache: CachedOutput
- root: JsonElement
- path: Path
说明:
TODO
代码
public interface DataProvider {
ToIntFunction<String> FIXED_ORDER_FIELDS = Util.make(new Object2IntOpenHashMap<>(), m -> {
m.put("type", 0);
m.put("parent", 1);
m.defaultReturnValue(2);
});
Comparator<String> KEY_COMPARATOR = Comparator.comparingInt(FIXED_ORDER_FIELDS).thenComparing(e -> (String)e);
Logger LOGGER = LogUtils.getLogger();
CompletableFuture<?> run(CachedOutput cache);
String getName();
static <T> CompletableFuture<?> saveAll(CachedOutput cache, Codec<T> codec, PackOutput.PathProvider pathProvider, Map<Identifier, T> entries) {
return saveAll(cache, codec, pathProvider::json, entries);
}
static <T, E> CompletableFuture<?> saveAll(CachedOutput cache, Codec<E> codec, Function<T, Path> pathGetter, Map<T, E> contents) {
return saveAll(cache, e -> codec.encodeStart(JsonOps.INSTANCE, (E)e).getOrThrow(), pathGetter, contents);
}
static <T, E> CompletableFuture<?> saveAll(CachedOutput cache, Function<E, JsonElement> serializer, Function<T, Path> pathGetter, Map<T, E> contents) {
return CompletableFuture.allOf(contents.entrySet().stream().map(entry -> {
Path path = pathGetter.apply(entry.getKey());
JsonElement json = serializer.apply(entry.getValue());
return saveStable(cache, json, path);
}).toArray(CompletableFuture[]::new));
}
static <T> CompletableFuture<?> saveStable(CachedOutput cache, HolderLookup.Provider registries, Codec<T> codec, T value, Path path) {
RegistryOps<JsonElement> ops = registries.createSerializationContext(JsonOps.INSTANCE);
return saveStable(cache, ops, codec, value, path);
}
static <T> CompletableFuture<?> saveStable(CachedOutput cache, Codec<T> codec, T value, Path path) {
return saveStable(cache, JsonOps.INSTANCE, codec, value, path);
}
private static <T> CompletableFuture<?> saveStable(CachedOutput cache, DynamicOps<JsonElement> ops, Codec<T> codec, T value, Path path) {
JsonElement json = codec.encodeStart(ops, value).getOrThrow();
return saveStable(cache, json, path);
}
static CompletableFuture<?> saveStable(CachedOutput cache, JsonElement root, Path path) {
return CompletableFuture.runAsync(() -> {
try {
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
HashingOutputStream hashedBytes = new HashingOutputStream(Hashing.sha1(), bytes);
try (JsonWriter jsonWriter = new JsonWriter(new OutputStreamWriter(hashedBytes, StandardCharsets.UTF_8))) {
jsonWriter.setSerializeNulls(false);
jsonWriter.setIndent(" ");
GsonHelper.writeValue(jsonWriter, root, KEY_COMPARATOR);
}
cache.writeIfNeeded(path, bytes.toByteArray(), hashedBytes.hash());
} catch (IOException var10) {
LOGGER.error("Failed to save file to {}", path, var10);
}
}, Util.backgroundExecutor().forName("saveStable"));
}
@FunctionalInterface
public interface Factory<T extends DataProvider> {
T create(PackOutput output);
}
}引用的其他类
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
参数
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
GsonHelper.writeValue()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Util.backgroundExecutor(), Util.make()
- 引用位置: