Overriding assetIndex with a component
Operating System
Linux
Version of Prism Launcher
Prism Launcher 8.4
Version of Qt
Qt 6.7.2
Description of bug
Attempting to add a custom json with assets such as https://mcphackers.github.io/assets/empty.json or https://files.betacraft.uk/launcher/v2/assets/indexes/b1.7.json will be ignored by the launcher
Steps to reproduce
Add a new instance, select a1.1.2_01 (any other version within alpha and beta range should reproduce this too) Import Components and select the following json:
{
"assetIndex": {
"id": "empty",
"sha1": "62ea787c1f800c091b98678b050453a5ae59d7bc",
"size": 14,
"totalSize": 0,
"url": "https://mcphackers.github.io/assets/empty.json"
},
"requires": [
{
"uid": "net.minecraft"
}
],
"formatVersion": 1,
"name": "Assets",
"uid": "org.multimc.custom.assets",
"version": "1"
}
Make sure the component is bottom-most in version tab of the instance.
Run the game and check the command line in logs. --assetIndex will be pre-1.6 instead of empty as specified by the json.
Suspected cause
Components other than "net.minecraft" don't seem to read this key at all.
This issue is unique
- [X] I have searched the issue tracker and did not find an issue describing my bug.
I don't know how exactly assetIndex behaves, but libraries are concatenated from all components - it does not override the array but append to it.
So if Component A has {"libraries":[{"name": "org.acme:lib:3.0", "url": "https://acme.org/maven"}]} and Component B has {"libraries":[{"name": "org.acme:lib2:1.0", "url": "https://acme.org/maven"}]}, Java would be launched with -classpath lib-3.0.jar:lib2-1.0.jar. The order of libraries specificied in the classpath doesn't usually matter, but as you might know if multiple jars contain the same resource it is taken from the jar specified earlier.
Oh yeah sorry, I wasn't very clear about libraries. Yes libraries are appended, but they're appended in a way which favors libraries in components from top over bottom. So if you have something that overrides class, it needs to be above the component which initially provides a library with that class.
So to override for example paulscode (sound library for minecraft) which used to be distributed within jar for earlier versions like alpha and beta. You need a component such as this one, which is also ordered to be above Minecraft component:
{
"libraries": [
{
"name": "com.paulscode:codecjorbis:20230120",
"url": "https://mcphackers.github.io/libraries/"
},
{
"name": "com.paulscode:codecwav:20101023",
"url": "https://libraries.minecraft.net/"
},
{
"name": "com.paulscode:libraryjavasound:20101123",
"url": "https://libraries.minecraft.net/"
},
{
"name": "com.paulscode:librarylwjglopenal:20100824",
"url": "https://libraries.minecraft.net/"
},
{
"name": "com.paulscode:soundsystem:20120107",
"url": "https://libraries.minecraft.net/"
}
],
"requires": [
{
"uid": "net.minecraft"
}
],
"formatVersion": 1,
"name": "Paulscode",
"uid": "com.paulscode",
"version": "1.0"
}
Updated paulscode is benefitial and actually fixes some sounds being cut off on the very last few milliseconds. However that's besides the point and out of scope of this issue. Point is, there is no objective priority on json keys. For some things you need to order them to be below certain components for changes to apply and for some to be above. for mainClass and minecraftArguments - below, for libraries and assetIndex - above
On second thought, I don't think overriding assetIndex or putting a library earlier on classpath (when there are multiple libraries providing the same class e.g. same library of different version) is a common use case. If that's fixed to be favored from bottom components then it shouldn't break existing setups.
It doesn't looks like asset index override works at all. I must have misremembered. As for libraries I 'll open a separate issue