Skip to content

Client crash when pressing F3 inside a Compact Machine #646

Closed as duplicate

Description

@twothe

I am not using performance mods.

  • Confirm

Description

Pressing F3 (debug HUD) while the player is inside a Compact Machine room crashes the client.
The crash happens in the Compact Machines debug overlay path: RoomMetadataDebugOverlay.render(...) calls CompactMachines.room(...), which dereferences a null ROOM_REGISTRAR and throws a NullPointerException.

This is reproducible with CompactMachines 7.0.68 on Minecraft 1.21.1 with NeoForge 21.1.212. The crash occurs before any third-party HUD mods can handle it; removing client performance mods (e.g. ImmediatelyFast/Iris/Sodium) does not change the stack origin.

Mod Version

7.0.68

Forge Version

21.1.212

Link to Crash Log

No response

Screenshot (if available)

No response

How to reproduce

  1. Start a 1.21.1 instance with NeoForge 21.1.212 and CompactMachines 7.0.68.
  2. Enter any Compact Machine room (e.g., via Personal Shrinking Device).
  3. Press F3 to open the debug HUD.
  4. Observed: The client crashes immediately.

Activity

  1. added
    unverifiedIssue needs to be verified beyond initial report, or due to an old version.
    21.1Relates to CM7 for MC 21.1
    on Dec 9, 2025
  2. twothe commented on Dec 9, 2025

    @twothe
    Author

    ChatGPT Analysis

    Root cause:
    CompactMachines.room(String) dereferences the static ROOM_REGISTRAR without a null check. On the client, during debug overlay rendering, ROOM_REGISTRAR has not been populated (it's set via reloadServices(MinecraftServer) on the server side). The call chain from RoomMetadataDebugOverlay.render(...) -> CompactMachines::room therefore NPEs.

    Minimal, safe fix (backwards-compatible):

    diff --git a/core-api/src/main/java/dev/compactmods/machines/api/CompactMachines.java b/core-api/src/main/java/dev/compactmods/machines/api/CompactMachines.java
    index XXXXX..YYYYY 100644
    --- a/core-api/src/main/java/dev/compactmods/machines/api/CompactMachines.java
    +++ b/core-api/src/main/java/dev/compactmods/machines/api/CompactMachines.java
    @@ -130,9 +130,14 @@ public final class CompactMachines {
         @ApiStatus.Internal
         private static IRoomRegistrar ROOM_REGISTRAR;
    
         public static Optional<RoomInstance> room(String roomCode) {
    -        return ROOM_REGISTRAR.get(roomCode);
    +        // Guard against client-side calls before server registrar is available.
    +        final IRoomRegistrar reg = ROOM_REGISTRAR;
    +        if (reg == null || roomCode == null) {
    +            return Optional.empty();
    +        }
    +        return reg.get(roomCode);
         }
     }

    Why this is sufficient:

    • RoomMetadataDebugOverlay.render(...) already uses Optional.flatMap(CompactMachines::room); returning Optional.empty() when the registrar is unavailable cleanly short-circuits overlay rendering without crashing.
    • No server behavior changes; once reloadServices(MinecraftServer) initializes ROOM_REGISTRAR, CompactMachines.room(...) works as before.
  3. Gaz492 commented on Dec 12, 2025

    @Gaz492

    Just going to forward a report we had over on the FTB Issue tracker for this as well.
    You can find a crashlog at https://pste.me/@OUsPxuxTedU
    FTBTeam/FTB-Modpack-Issues#11015

  4. Mimexe commented on Dec 12, 2025

    @Mimexe

    duplicate of #638 ?

  5. robotgryphon commented on Dec 21, 2025

    @robotgryphon
    Collaborator

    This is caused by the same issue as #638 - registration methods being hit before services are loading. Merging into that ticket...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    21.1Relates to CM7 for MC 21.1triageunverifiedIssue needs to be verified beyond initial report, or due to an old version.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions