Skip to content

[bug]server crash: PreConstructEventHelper loads client-only BakedModel during listener discovery #3

Description

@jim139129

Environment

  • Minecraft: 1.21.1
  • NeoForge: 21.1.243
  • Create: 6.0.10
  • Azimuth: 1.4.2
  • Environment: Dedicated server

Issue

The server crashes during mod construction after updating to Azimuth 1.4.2.

The root error is:

java.lang.RuntimeException: Attempted to load class
net/minecraft/client/resources/model/BakedModel
for invalid dist DEDICATED_SERVER

The relevant stack trace goes through Azimuth:

at java.lang.Class.getDeclaredMethods(Class.java:2329)
at com.cake.azimuth.foundation.preconstruct.PreConstructEventHelper.resolveRegistratorMethod(PreConstructEventHelper.java:54)
at com.cake.azimuth.foundation.preconstruct.PreConstructEventHelper.discoverListeners(PreConstructEventHelper.java:31)
at com.cake.azimuth.foundation.preconstruct.PreConstructEventHelper.post(PreConstructEventHelper.java:89)
at com.cake.azimuth.registration.CreateBlockEdits.bootstrapIfTheBootIsNotStrapped(CreateBlockEdits.java:35)
at com.simibubi.create.AllBlocks.

This causes Create's AllBlocks initialization to fail. Several Create addons then fail secondarily, including Steam 'n' Rails, Create: Framed, Create Railways Navigator, Create Bits 'n' Bobs, and Create Aeronautics.

Suspected cause

PreConstructEventHelper.resolveRegistratorMethod() calls owner.getDeclaredMethods() while discovering every @AzPreConstructEventListener.
On a dedicated server, getDeclaredMethods() resolves the signatures of all methods in the listener owner class. If that class contains any method referencing a client-only type such as BakedModel, NeoForge rejects it before Azimuth can filter to the annotated listener method.
This means a client-only method in the same class as a pre-construct listener can crash the dedicated server even when that method is never invoked.

Expected behavior

Dedicated servers should only resolve and invoke the exact listener method recorded in ModFileScanData, without resolving unrelated client-only method signatures.

Suggested fix

Resolve the target method directly from AnnotationData.memberName() and its descriptor instead of calling Class#getDeclaredMethods(). Alternatively, ensure client-only listener owners are excluded from dedicated-server discovery.

Notes

The faulty pre-construct listener discovery implementation appears to have been introduced in the 1.4.0 pre-construct event system. The 1.4.2 changes do not appear to modify this specific code path, but 1.4.2 contains the issue and triggers it in this modpack.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions