NPE occurs when custom DirectoryResourcePack uses zipfs #8

Closed
opened 2024-04-02 18:15:24 +02:00 by teddyxlandlee · 1 comment

This is the log: https://mclo.gs/j8wVkV9

This error is due to not considering DirectoryResourcePack#root being root path of a non-default filesystem, e.g. zipfs (jar://file://path/to/file.zip!/).

ResourcePackManagerMixin, Line 51

if (pack != null) dataLocation = pack.getParent().resolve(pack.getFileName() + Respackopts.FILE_EXTENSION);

In default filesystem, a DirectoryResourcePack (mojmapped PathPackResource) should never be at the root. However, 3rd-party mods may implement it with a custom fs (e.g. Remote Resource Pack Mod (code) in this crash log), which crashes the game.

To solve this NPE, you can simply add a filter:

if (pack != null && path.getParent()) // DRP logic

Have a nice day!

This is the log: https://mclo.gs/j8wVkV9 This error is due to not considering `DirectoryResourcePack#root` **being root path of a non-default filesystem**, e.g. `zipfs` (`jar://file://path/to/file.zip!/`). `ResourcePackManagerMixin`, Line 51 ```java if (pack != null) dataLocation = pack.getParent().resolve(pack.getFileName() + Respackopts.FILE_EXTENSION); ``` In default filesystem, a `DirectoryResourcePack` (mojmapped `PathPackResource`) should never be at the root. However, 3rd-party mods may implement it with a custom fs (e.g. [Remote Resource Pack](https://modrinth.com/mod/remote-resource-pack) Mod [(code)](https://github.com/teddyxlandlee/remote-resource-pack/blob/1.20/common/src/main/java/xland/mcmod/remoteresourcepack/RRPCacheRepoSource.java#L55) in this crash log), which crashes the game. To solve this NPE, you can simply add a filter: ```java if (pack != null && path.getParent()) // DRP logic ``` Have a nice day!
Owner

I have added a null check to the parent since doing so didn't take much effort, but I'd recommend taking a second look at some of the choices made when designing your mod, since they seem liable to further unintended compatibility issues.
Perhaps you could look at my mod Resclone for reference (or perhaps implementation) since it seems to target a similar use case.

I have added a null check to the parent since doing so didn't take much effort, but I'd recommend taking a second look at some of the choices made when designing your mod, since they seem liable to further unintended compatibility issues. Perhaps you could look at my mod Resclone for reference (or perhaps implementation) since it seems to target a similar use case.
Comment
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: JfMods/Respackopts#8
No description provided.