TerraformersMC / Terraform

Base library for the Terraformers' mods
GNU Lesser General Public License v3.0
37 stars 16 forks source link

Terraform boat API initialization issues #70

Open gniftygnome opened 1 year ago

gniftygnome commented 1 year ago

The 1.19.3 version of Terraform wood API's boat implementation originally would crash during startup if no mod defined a boat:

Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.terraformersmc.terraform.boat.api.TerraformBoatTypeRegistry
    at com.terraformersmc.terraform.boat.impl.client.TerraformBoatEntityRenderer.<init>(TerraformBoatEntityRenderer.java:33) ~[terraform-wood-api-v1-5.0.0-alpha.3.1.jar:?]
    at com.terraformersmc.terraform.boat.impl.client.TerraformBoatClientInitializer.lambda$onInitializeClient$0(TerraformBoatClientInitializer.java:14) ~[terraform-wood-api-v1-5.0.0-alpha.3.1.jar:?]
    at net.minecraft.client.render.entity.EntityRenderers.redirect$zin000$createEntityRenderer(EntityRenderers.java:559) ~[minecraft-project-@-merged-named.jar:?]
[...]

I hackishly worked around the problem with this change: https://github.com/TerraformersMC/Terraform/commit/65c2a969179af418e40712333aa518c54b274d90#diff-3aa7742763ec6703e9cc5d27b7ebc52970decc139eea351819a97b41f38b3580

However although using the wood API without any boats (a normal Nether implementation) now works correctly, it does issue an ERROR grade log line during start-up which may alarm somebody:

[12:52:38] [Render thread/ERROR] (Minecraft) Registry 'terraform:boat' was empty after loading

Perhaps the way to resolve this would be to add a dummy registry entry during startup, but I kind of hope somebody else knows a better way.

haykam821 commented 3 months ago

Fabric API has an upstream issue tracking intentionally empty registries such as Terraform's boat types: FabricMC/fabric#3128. A mixin of our own shouldn't be too difficult either, but the injection point is within a lambda method and somewhat annoying to determine.