Wilder World

Wilder World

1M Downloads

[1.18.2] Client crash(disconnect) on server when near a naturally spawned Butterfly or just when spawning one in with a spawn egg.

Gbergz opened this issue ยท 2 comments

commented

^ Client crash on server when near a Butterfly.

To rejoin you have to kill it some way, either with commands if you're super fast while joining.
Using a spawn egg to spawn it will instantly disconnect your from the server.

Versions:
Wilder World: 2.2.2 | https://www.curseforge.com/minecraft/mc-mods/wilder-world/files/3825335
Fabric API: fabric-api-0.59.0+1.18.2.jar
Fabric Loader: 0.14.9-1.18.2

Logs with the error: https://gist.github.com/Gbergz/170c32f2a1c8b73c6d7e1669bf7754e5

Edit: the entity name and spawn egg name are also unlocalized.

commented

This crash happens because sounds are not being properly registered. See: https://fabric.moddedmc.wiki/items#registering-an-item for an explanation but in short you need to statically initialize the class with the registry method you are using. This literally just means adding a static method which u can call. Like so...

public static void initialize() {}

The call you use atm using new is a dynamic initializer. This won't guarantee that the static variables are initialized and so at any point the game might decide it doesn't care about the sounds object you created and garbage collect it, then suddenly you have no sound id.

commented

Forgot to mention but this extends to all the registration classes u have. Sorry to dump this on you haha it's not immediately obvious when u start learning java or even after doing it for a while. I just learnt about this like last month.