Aquaculture 2

Aquaculture 2

95M Downloads

Incompatibility with Roughly Enough Resources - "Invalid player data"

unilock opened this issue ยท 7 comments

commented

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:

  1. Install Aquaculture 2.
  2. Install Roughly Enough Items + dependencies.
  3. Install Roughly Enough Resources.
  4. Start game; create and join a new world.
  5. Error.

Screenshot:
image
(it says "Back to Server List" regardless of whether you're joining a singleplayer or multiplayer world)

Versions:

Relevant bit of latest.log, snipped from when creating a new world:
https://gist.github.com/unilock/fd9b4942846ddb16fb9678b50e9a9f46#file-latest-log

Relevant issue: #364

commented

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?

commented

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/

commented

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.

commented

Unfortunately, that build did not solve the issue :(

But, I think I did! (probably not in the "best" way, but it does work!)


Here:

object.addProperty("add", object.getAsBoolean());

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)

commented

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/

commented

Everything's working on my end! Thanks! :)

commented

I'm getting the same issue on 1.19.2