-
Notifications
You must be signed in to change notification settings - Fork 433
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resource Loader v1 #3083
base: 1.20
Are you sure you want to change the base?
Resource Loader v1 #3083
Conversation
...ls-v0/src/testmodClient/java/net/fabricmc/fabric/test/model/SpecificModelReloadListener.java
Show resolved
Hide resolved
fabric-api-base/src/main/java/net/fabricmc/fabric/impl/base/event/SortableNode.java
Outdated
Show resolved
Hide resolved
fdc66ad
to
614ad84
Compare
614ad84
to
294923f
Compare
import net.fabricmc.fabric.api.event.EventFactory; | ||
import net.fabricmc.fabric.api.resource.loader.v1.ResourceReloaderHolder; | ||
|
||
public final class ClientResourceReloadEvents { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All classes should have a javadoc, IMO.
|
||
public final class ClientResourceReloadEvents { | ||
/** | ||
* Event to register resource reloaders for client resource packs (i.e. {@link ResourceType#CLIENT_RESOURCES}). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this gets cut at i.e.
when in summary.
}); | ||
|
||
/** | ||
* Event that fires right when the resource reloaders finish running, but before subsequent cleanup has been performed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "has been performed" is appropriate here, you can just use "occurs"
}); | ||
|
||
@FunctionalInterface | ||
public interface RegisterReloaders { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs javadoc.
} | ||
|
||
@FunctionalInterface | ||
public interface StartReload { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs javadoc.
import net.fabricmc.fabric.api.event.Event; | ||
import net.fabricmc.fabric.api.event.EventFactory; | ||
|
||
public final class ServerResourceReloadEvents { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Classes should have javadocs.
@ApiStatus.NonExtendable | ||
public interface RegisterContext extends Context { | ||
/** | ||
* Register a new resource reloader. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registers.
void addReloader(Identifier identifier, ResourceReloader reloader); | ||
|
||
/** | ||
* Request that <b>the apply phase</b> of one reloader be executed before <b>the apply phase</b> of another reloader. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requests.
* @param firstReloader The identifier of the reloader that should run before the other. | ||
* @param secondReloader The identifier of the reloader that should run after the other. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Param javadoc should be lowercase, no period
@@ -4,3 +4,7 @@ accessible method net/minecraft/resource/NamespaceResourceManager getMetadataPat | |||
accessible method net/minecraft/resource/NamespaceResourceManager loadMetadata (Lnet/minecraft/resource/InputSupplier;)Lnet/minecraft/resource/metadata/ResourceMetadata; | |||
accessible field net/minecraft/resource/FileResourcePackProvider source Lnet/minecraft/resource/ResourcePackSource; | |||
accessible field net/minecraft/resource/ResourcePackManager providers Ljava/util/Set; | |||
accessible class net/minecraft/server/MinecraftServer$ResourceManagerHolder | |||
accessible field net/minecraft/resource/ReloadableResourceManagerImpl reloaders Ljava/util/List; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extraneous line?
@Technici4n any progress? |
No, I don't think I will be finishing this. |
A much needed update to resource loader.
Resource Reload Events
ClientResourceReloadEvents
andServerResourceReloadEvents
are added to hold new events.START_RELOAD
fires right before resource reloaders start running, and can for example be used to invalidate a cache before the resource reloader recomputes it.END_RELOAD
fires right when the reload completes (successfully or with a failure).END_RELOAD
to fire withoutSTART_RELOAD
having fired, if case something fails beforeSTART_RELOAD
.REGISTER_RELOADERS
: see below.Resource Reloaders
REGISTER_RELOADERS
events.getFabricId
had to be overridden).DataPackContents
; on the client they are instantiated once and then stored insideMinecraftClient
.ResourceReloaderHolder
.DataPackContents
andMinecraftClient
to be captured for cross-reloader talk during the apply phase.REGISTER_RELOADERS
event only fires exactly once at the start of the game, but I figured it would still be nicer for consistency to have an event.LegacyReloaderHolder
because the new client event is client-only, whereas the old API was side agnostic (since it did not provide any context whatsoever).Here is an example of using this new API for a client reloader. I am not fully convinced by this usage pattern yet:
For server reloaders however, this matches what vanilla does, and is much nicer than what the v0 API provides today.
Resource Packs
ResourcePackHelper
, perhaps a better name should be found?ResourcePack
instances. SeeResourcePackRegistrationEvents#afterMods(ResourceType)
andafterAll(ResourceType)
.ResourceManager
that allows inspecting the previous packs. This can be useful for virtual resource packs, among other things, however note that this API does not provide the virtual resource pack implementation itself.ResourcePackHelper#createModResourcePack
to directly instantiate mod nio resource packs. This can be useful to access resources in a mod JAR outside of the normal resource loading lifecycle.Further possibilities
ResourcePackProvider
s orResourcePackProfile
s. This can be left for a future PR imo. This would either be an event (maybe inResourcePackRegistrationEvents
), or a static registration inResourcePackHelper
.TODO items
ModResourcePack
on its builtin packs too?ResourcePackHelper
.ModNioResourcePack
entirely. Or can also be left for a future PR.ResourcePackRegistrationEvents
isFirst
to the context ofResourcePackRegistrationEvents
. I think it can be left for later, it's a bit annoying.ResourceReloaderKeys
for all the vanilla reloaders? Many are missing on the client side.