Resource Loader V2#62
Open
SpaceWalkerRS wants to merge 6 commits intogen2from
Open
Conversation
15a15a0 to
e041ddc
Compare
e041ddc to
75b02bf
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
V2 is a major rewrite of the Resource Loader API, mostly focusing on adding new features. V1 had three main features.
The resource management system was otherwise left untouched. The rewrite expands the resource management system with new features and improves the API's integration with Vanilla.
Several of these were achieved by abstracting the resource management system and replacing a few Vanilla components with wrappers around equivalent OSL components. This way the Vanilla system remains intact and usable, while it is also possible to use the OSL system instead. This allows for more powerful features down the line.
Resource Loader V2
I had several goals for V2, but they can be boiled down to: feature parity across Minecraft versions.
On a high level, this means adding support for resource packs and data packs. Specifically, supporting data packs in 1.12- and resource packs in 1.5-. Resource packs are more robust and feature-rich than the old texture packs, and I want mods to be able to take advantage of that even in older versions.
On a low level, it's about adding certain functionality that is already present in some Minecraft versions, but not others. Some examples are functions such as
ResourceManager.getResources,ResourceManager.listResources, and asynchronous resource reloads.Additionally, supporting Minecraft versions before Alpha 1.2.2 was a big goal. Texture packs were already limited, but before texture packs there was no resource management in the game at all. Back-porting such a system is essential for other APIs to get off the ground.
With this in mind I opted to create one single complete resource management system that is independent from any Vanilla system. This was already necessary for pre-texture pack support, but it makes achieving feature-parity easier as will be interacting with OSL's system, so the Vanilla system need not be augmented.
Updating From V1
Events
The following events were removed:
ADD_DEFAULT_TEXTURE_PACKS(1.5-).ADD_DEFAULT_RESOURCE_PACKS(1.6+).ADD_DEFAULT_DATA_PACKS(1.13+).There are two possible update paths
Registering Custom Bundled Mod Resources
The
ResourcePackRepositoryclass has a method for registering bundled mod resources from a sub-directory in your project resources.Registering Custom Resource Pack Repository Source
If you want to register custom resource packs from elsewhere, you can register a custom
ResourcePackRepository.Source, which gives complete freedom of what kind of resource packs you load in.API classes
The following pack-related API classes were removed.
ModTexturePack(1.5-).ModResourcePack(1.6-1.12).ModPack(1.13+).ResourceUtils(1.6+).There is no equivalent for the pack-related classes in the rewrite, but the update path for their main use (default texture/resource packs) was covered in the previous section.
net.ornithemc.osl.resource.loader.api.resource.pack.ResourcePackis the base class for all resource packs.AbstractResourcePackin the same package is an implementation that manages namespaces and resource metadata.ResourceUtilswas also removed without a replacement. If you have suggestions for a solution or have a use-case for this that now goes un-met, please leave a comment.Localization
All localization-related code has been removed to be made into a separate API (see #58).
Notes on Compatibility
Given the nature of the rewrite, almost all OSL internals have been changed in some way. If your mod relied on any internals, chances are high it will need updating.
The rewrite also changes how Vanilla-integration is done. In particular, the
resourceManagerandpackRepositoryinMinecraft/MinecraftServerhave been replaced with wrappers around OSL's own resource managers and pack repositories. This means any Mixins intoSimpleReloadableResourceManager,FallbackResourceManager, andPackRepositoryare likely to have no effect whatsoever. If you have reason to modify these classes, please leave a comment, as there may be a way to add the desired change/functionality to OSL in this rewrite.