Incompatibility with Roughly Enough Resources - "Invalid player data"
unilock opened this issue ยท 7 comments
With Aquaculture 2 installed alongside Roughly Enough Resources, the player is unable to join any world, with the error message "Invalid player data".
To reproduce:
- Install Aquaculture 2.
- Install Roughly Enough Items + dependencies.
- Install Roughly Enough Resources.
- Start game; create and join a new world.
- Error.
Screenshot:
(it says "Back to Server List" regardless of whether you're joining a singleplayer or multiplayer world)
Versions:
- Minecraft: 1.18.2
- Forge: 40.2.0
- Aquaculture 2: 2.3.10
- Roughly Enough Resources: (this PR cherry-picked into the latest official 1.18.2 branch - here's a JAR, but feel free to build it yourself if you don't trust me (i don't!))
- Roughly Enough Items: 8.3.590
- REI Plugin Compatibilities: 8.0.46 (for JEI plugin support)
- Architectury API: 4.11.89
- Cloth Config API: 6.4.90
- McMouser: 1.0.0 (for convenience)
Relevant bit of latest.log
, snipped from when creating a new world:
https://gist.github.com/unilock/fd9b4942846ddb16fb9678b50e9a9f46#file-latest-log
Relevant issue: #364
If it helps, the dev of Enigmatic Legacy fixed the same issue on their end in their 1.19.2 branch:
Aizistral-Studios/Enigmatic-Legacy@857aa21
I (hackily) cherry-picked that commit into its 1.18.X branch, and it worked fine.
Maybe something similar can be done in Aquaculture?
There is not much in that commits, that really relates to stuff AQ2 does tbf.
Only thing that it maybe could be, is the added event.enqueueWork. I've tried doing that in AQ2 as well, so see if it helps
A build will be available here shortly to test :)
https://jenkins.girafi.dk/job/Team%20Metallurgy%20Mods/job/Aquaculture/job/Aquaculture%202%201.18/28/
Thanks for the very thorough report!
I was able to reproduce the issue. But it looks like it's unfortunately caused by Roughly Enough Resources.
Don't think there is much I can do about it on my end.
Unfortunately, that build did not solve the issue :(
But, I think I did! (probably not in the "best" way, but it does work!)
Here:
I think Gson is tripping up, because the "add"
element doesn't exist in Aquaculture's fishing loot tables - so it's trying to convert nothing into a boolean.
Gson's getAsBoolean()
requires that the element being passed be a JsonPrimitive
or a JsonArray
- neither of which a non-existent element is, obviously.
I replaced the above line of code with this:
object.addProperty("add", net.minecraft.util.GsonHelper.getAsBoolean(object, "add", false));
GsonHelper#getAsBoolean
is a built-in method that checks if an object contains a given element, and if it does not, returns a default value.
In this case, if the "add"
element does exist under the biome_tag_check
condition, the method returns the value of said element as it is; if the element does not exist, the method returns false
by default.
As far as I've tested, it works! Aquaculture fish are still only caught in their defined biome types (so the "biome_tag_check" condition is being considered correctly), and vanilla Minecraft fish can still be caught as well.
I'm not sure of the implications of this when an "add" element does exist in a loot table object, as I have nothing to test with. But, since this is what Minecraft uses for its own loot tables, I assume it would be fine.
(note that the above "fix" is functionally equivalent to
if (object.has("add")) {
object.addProperty("add", object.getAsBoolean());
} else {
object.addProperty("add", false);
}
}
...probably)
Excellent detective work!
I've tried implementing the fix. Here is a Jenkins build with the fix:
https://jenkins.girafi.dk/job/Team%20Metallurgy%20Mods/job/Aquaculture/job/Aquaculture%202%201.18/