BiomeParametersDumpReport.java

net.minecraft.data.info.BiomeParametersDumpReport

信息

  • 全限定名:net.minecraft.data.info.BiomeParametersDumpReport
  • 类型:public class
  • 包:net.minecraft.data.info
  • 源码路径:src/main/java/net/minecraft/data/info/BiomeParametersDumpReport.java
  • 起始行号:L27
  • 实现:DataProvider
  • 职责:

    TODO

字段/常量

  • LOGGER

    • 类型: Logger
    • 修饰符: private static final
    • 源码定位: L28
    • 说明:

      TODO

  • topPath

    • 类型: Path
    • 修饰符: private final
    • 源码定位: L29
    • 说明:

      TODO

  • registries

    • 类型: CompletableFuture<HolderLookup.Provider>
    • 修饰符: private final
    • 源码定位: L30
    • 说明:

      TODO

  • ENTRY_CODEC

    • 类型: MapCodec<ResourceKey<Biome>>
    • 修饰符: private static final
    • 源码定位: L31
    • 说明:

      TODO

  • CODEC

    • 类型: Codec<Climate.ParameterList<ResourceKey<Biome>>>
    • 修饰符: private static final
    • 源码定位: L32
    • 说明:

      TODO

内部类/嵌套类型

构造器

public BiomeParametersDumpReport(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) @ L34

  • 构造器名:BiomeParametersDumpReport
  • 源码定位:L34
  • 修饰符:public

参数:

  • output: PackOutput
  • registries: CompletableFuture<HolderLookup.Provider>

说明:

TODO

方法

下面的方法块按源码顺序生成。

public CompletableFuture<?> run(CachedOutput cache) @ L39

  • 方法名:run
  • 源码定位:L39
  • 返回类型:CompletableFuture<?>
  • 修饰符:public

参数:

  • cache: CachedOutput

说明:

TODO

private static <E> CompletableFuture<?> dumpValue(Path path, CachedOutput cache, DynamicOps<JsonElement> ops, Encoder<E> codec, E value) @ L57

  • 方法名:dumpValue
  • 源码定位:L57
  • 返回类型: CompletableFuture<?>
  • 修饰符:private static

参数:

  • path: Path
  • cache: CachedOutput
  • ops: DynamicOps
  • codec: Encoder
  • value: E

说明:

TODO

private Path createPath(Identifier element) @ L62

  • 方法名:createPath
  • 源码定位:L62
  • 返回类型:Path
  • 修饰符:private

参数:

  • element: Identifier

说明:

TODO

public final String getName() @ L66

  • 方法名:getName
  • 源码定位:L66
  • 返回类型:String
  • 修饰符:public final

参数:

说明:

TODO

代码

public class BiomeParametersDumpReport implements DataProvider {
    private static final Logger LOGGER = LogUtils.getLogger();
    private final Path topPath;
    private final CompletableFuture<HolderLookup.Provider> registries;
    private static final MapCodec<ResourceKey<Biome>> ENTRY_CODEC = ResourceKey.codec(Registries.BIOME).fieldOf("biome");
    private static final Codec<Climate.ParameterList<ResourceKey<Biome>>> CODEC = Climate.ParameterList.codec(ENTRY_CODEC).fieldOf("biomes").codec();
 
    public BiomeParametersDumpReport(PackOutput output, CompletableFuture<HolderLookup.Provider> registries) {
        this.topPath = output.getOutputFolder(PackOutput.Target.REPORTS).resolve("biome_parameters");
        this.registries = registries;
    }
 
    @Override
    public CompletableFuture<?> run(CachedOutput cache) {
        return this.registries
            .thenCompose(
                registryAccess -> {
                    DynamicOps<JsonElement> registryOps = registryAccess.createSerializationContext(JsonOps.INSTANCE);
                    List<CompletableFuture<?>> result = new ArrayList<>();
                    MultiNoiseBiomeSourceParameterList.knownPresets()
                        .forEach(
                            (preset, parameterList) -> result.add(
                                dumpValue(this.createPath(preset.id()), cache, registryOps, CODEC, (Climate.ParameterList<ResourceKey<Biome>>)parameterList)
                            )
                        );
                    return CompletableFuture.allOf(result.toArray(CompletableFuture[]::new));
                }
            );
    }
 
    private static <E> CompletableFuture<?> dumpValue(Path path, CachedOutput cache, DynamicOps<JsonElement> ops, Encoder<E> codec, E value) {
        Optional<JsonElement> result = codec.encodeStart(ops, value).resultOrPartial(e -> LOGGER.error("Couldn't serialize element {}: {}", path, e));
        return result.isPresent() ? DataProvider.saveStable(cache, result.get(), path) : CompletableFuture.completedFuture(null);
    }
 
    private Path createPath(Identifier element) {
        return element.withSuffix(".json").resolveAgainst(this.topPath);
    }
 
    @Override
    public final String getName() {
        return "Biome Parameters";
    }
}

引用的其他类