ReloadableServerResources.java

net.minecraft.server.ReloadableServerResources

信息

  • 全限定名:net.minecraft.server.ReloadableServerResources
  • 类型:public class
  • 包:net.minecraft.server
  • 源码路径:src/main/java/net/minecraft/server/ReloadableServerResources.java
  • 起始行号:L23
  • 职责:

    TODO

字段/常量

  • LOGGER

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

      TODO

  • DATA_RELOAD_INITIAL_TASK

    • 类型: CompletableFuture<Unit>
    • 修饰符: private static final
    • 源码定位: L25
    • 说明:

      TODO

  • fullRegistryHolder

    • 类型: ReloadableServerRegistries.Holder
    • 修饰符: private final
    • 源码定位: L26
    • 说明:

      TODO

  • commands

    • 类型: Commands
    • 修饰符: private final
    • 源码定位: L27
    • 说明:

      TODO

  • recipes

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

      TODO

  • advancements

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

      TODO

  • functionLibrary

    • 类型: ServerFunctionLibrary
    • 修饰符: private final
    • 源码定位: L30
    • 说明:

      TODO

  • postponedTags

    • 类型: List<Registry.PendingTags<?>>
    • 修饰符: private final
    • 源码定位: L31
    • 说明:

      TODO

  • newComponents

    • 类型: List<DataComponentInitializers.PendingComponents<?>>
    • 修饰符: private final
    • 源码定位: L32
    • 说明:

      TODO

内部类/嵌套类型

构造器

private ReloadableServerResources(LayeredRegistryAccess<RegistryLayer> fullLayers, HolderLookup.Provider loadingContext, FeatureFlagSet enabledFeatures, Commands.CommandSelection commandSelection, List<Registry.PendingTags<?>> postponedTags, PermissionSet functionCompilationPermissions, List<DataComponentInitializers.PendingComponents<?>> newComponents) @ L34

  • 构造器名:ReloadableServerResources
  • 源码定位:L34
  • 修饰符:private

参数:

  • fullLayers: LayeredRegistryAccess
  • loadingContext: HolderLookup.Provider
  • enabledFeatures: FeatureFlagSet
  • commandSelection: Commands.CommandSelection
  • postponedTags: List<Registry.PendingTags<?>>
  • functionCompilationPermissions: PermissionSet
  • newComponents: List<DataComponentInitializers.PendingComponents<?>>

说明:

TODO

方法

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

public ServerFunctionLibrary getFunctionLibrary() @ L52

  • 方法名:getFunctionLibrary
  • 源码定位:L52
  • 返回类型:ServerFunctionLibrary
  • 修饰符:public

参数:

说明:

TODO

public ReloadableServerRegistries.Holder fullRegistries() @ L56

  • 方法名:fullRegistries
  • 源码定位:L56
  • 返回类型:ReloadableServerRegistries.Holder
  • 修饰符:public

参数:

说明:

TODO

public RecipeManager getRecipeManager() @ L60

  • 方法名:getRecipeManager
  • 源码定位:L60
  • 返回类型:RecipeManager
  • 修饰符:public

参数:

说明:

TODO

public Commands getCommands() @ L64

  • 方法名:getCommands
  • 源码定位:L64
  • 返回类型:Commands
  • 修饰符:public

参数:

说明:

TODO

public ServerAdvancementManager getAdvancements() @ L68

  • 方法名:getAdvancements
  • 源码定位:L68
  • 返回类型:ServerAdvancementManager
  • 修饰符:public

参数:

说明:

TODO

public List<PreparableReloadListener> listeners() @ L72

  • 方法名:listeners
  • 源码定位:L72
  • 返回类型:List
  • 修饰符:public

参数:

说明:

TODO

public static CompletableFuture<ReloadableServerResources> loadResources(ResourceManager resourceManager, LayeredRegistryAccess<RegistryLayer> contextLayers, List<Registry.PendingTags<?>> updatedContextTags, FeatureFlagSet enabledFeatures, Commands.CommandSelection commandSelection, PermissionSet functionCompilationPermissions, Executor backgroundExecutor, Executor mainThreadExecutor) @ L76

  • 方法名:loadResources
  • 源码定位:L76
  • 返回类型:CompletableFuture
  • 修饰符:public static

参数:

  • resourceManager: ResourceManager
  • contextLayers: LayeredRegistryAccess
  • updatedContextTags: List<Registry.PendingTags<?>>
  • enabledFeatures: FeatureFlagSet
  • commandSelection: Commands.CommandSelection
  • functionCompilationPermissions: PermissionSet
  • backgroundExecutor: Executor
  • mainThreadExecutor: Executor

说明:

TODO

public void updateComponentsAndStaticRegistryTags() @ L117

  • 方法名:updateComponentsAndStaticRegistryTags
  • 源码定位:L117
  • 返回类型:void
  • 修饰符:public

参数:

说明:

TODO

代码

public class ReloadableServerResources {
    private static final Logger LOGGER = LogUtils.getLogger();
    private static final CompletableFuture<Unit> DATA_RELOAD_INITIAL_TASK = CompletableFuture.completedFuture(Unit.INSTANCE);
    private final ReloadableServerRegistries.Holder fullRegistryHolder;
    private final Commands commands;
    private final RecipeManager recipes;
    private final ServerAdvancementManager advancements;
    private final ServerFunctionLibrary functionLibrary;
    private final List<Registry.PendingTags<?>> postponedTags;
    private final List<DataComponentInitializers.PendingComponents<?>> newComponents;
 
    private ReloadableServerResources(
        LayeredRegistryAccess<RegistryLayer> fullLayers,
        HolderLookup.Provider loadingContext,
        FeatureFlagSet enabledFeatures,
        Commands.CommandSelection commandSelection,
        List<Registry.PendingTags<?>> postponedTags,
        PermissionSet functionCompilationPermissions,
        List<DataComponentInitializers.PendingComponents<?>> newComponents
    ) {
        this.fullRegistryHolder = new ReloadableServerRegistries.Holder(fullLayers.compositeAccess());
        this.postponedTags = postponedTags;
        this.newComponents = newComponents;
        this.recipes = new RecipeManager(loadingContext);
        this.commands = new Commands(commandSelection, CommandBuildContext.simple(loadingContext, enabledFeatures));
        this.advancements = new ServerAdvancementManager(loadingContext);
        this.functionLibrary = new ServerFunctionLibrary(functionCompilationPermissions, this.commands.getDispatcher());
    }
 
    public ServerFunctionLibrary getFunctionLibrary() {
        return this.functionLibrary;
    }
 
    public ReloadableServerRegistries.Holder fullRegistries() {
        return this.fullRegistryHolder;
    }
 
    public RecipeManager getRecipeManager() {
        return this.recipes;
    }
 
    public Commands getCommands() {
        return this.commands;
    }
 
    public ServerAdvancementManager getAdvancements() {
        return this.advancements;
    }
 
    public List<PreparableReloadListener> listeners() {
        return List.of(this.recipes, this.functionLibrary, this.advancements);
    }
 
    public static CompletableFuture<ReloadableServerResources> loadResources(
        ResourceManager resourceManager,
        LayeredRegistryAccess<RegistryLayer> contextLayers,
        List<Registry.PendingTags<?>> updatedContextTags,
        FeatureFlagSet enabledFeatures,
        Commands.CommandSelection commandSelection,
        PermissionSet functionCompilationPermissions,
        Executor backgroundExecutor,
        Executor mainThreadExecutor
    ) {
        return ReloadableServerRegistries.reload(contextLayers, updatedContextTags, resourceManager, backgroundExecutor)
            .thenCompose(
                fullRegistries -> CompletableFuture.<List<DataComponentInitializers.PendingComponents<?>>>supplyAsync(
                        () -> BuiltInRegistries.DATA_COMPONENT_INITIALIZERS.build(fullRegistries.lookupWithUpdatedTags()), backgroundExecutor
                    )
                    .thenCompose(
                        pendingComponents -> {
                            ReloadableServerResources result = new ReloadableServerResources(
                                fullRegistries.layers(),
                                fullRegistries.lookupWithUpdatedTags(),
                                enabledFeatures,
                                commandSelection,
                                updatedContextTags,
                                functionCompilationPermissions,
                                (List<DataComponentInitializers.PendingComponents<?>>)pendingComponents
                            );
                            return SimpleReloadInstance.create(
                                    resourceManager,
                                    result.listeners(),
                                    backgroundExecutor,
                                    mainThreadExecutor,
                                    DATA_RELOAD_INITIAL_TASK,
                                    LOGGER.isDebugEnabled()
                                )
                                .done()
                                .thenApply(ignore -> result);
                        }
                    )
            );
    }
 
    public void updateComponentsAndStaticRegistryTags() {
        this.postponedTags.forEach(Registry.PendingTags::apply);
        this.newComponents.forEach(DataComponentInitializers.PendingComponents::apply);
    }
}

引用的其他类