Skip to content

Lithium breaks menu in my mod Nukacraft #763

Open

Description

@Jetug

When Lithium is installed opening the power armor menu in my mod causes the world to crash

Version

lithium-neoforge-0.15.4+mc1.21.1

Reproduction Steps

  1. Install Nukacraft
  2. Place the Power Armor Frame.
  3. Shift + right click on it to open the menu
  4. World crashes

Crash Report File

disconnect-2026-07-25_01.06.54-client.txt

Minecraft Save

New World.zip

Additional Information

This is what the menu class looks like

PowerArmorMenu.java
ChassisMenu.java

Activity

  1. added
    A-mods
    T-crash
    on Jul 29, 2026
  2. 2No2Name commented on Jul 29, 2026

    @2No2Name
    Member

    From the log it is unclear why lithium should be causing this packet handling. Have you confirmed this does not happen without lithium?

  3. Jetug commented on Jul 29, 2026

    @Jetug
    Author

    Yes I checked without Lithium it doesn't crush. I only have Nukacraft and it's 2 dependencies installed (GeckoLib and NTGL) and only when I add Lithium it starts crushing

  4. E-R-Butch commented on Sep 28, 2026

    @E-R-Butch

    Hi @Jetug! We hit the same crash on our NeoForge 1.21.1 server pack and I dug into it a bit — the evidence points to a slot-count mismatch in the chassis menu itself rather than Lithium. Sharing in case it saves you some time:

    What the crash actually is

    The client dies while applying a container_set_content packet:

    java.lang.ArrayIndexOutOfBoundsException: Index 7 out of bounds for length 7
        at NonNullList.set → SimpleContainer.setItem → Slot.set
        at AbstractContainerMenu.initializeContents
        at ClientPacketListener.handleContainerContent
    

    That is vanilla container sync writing an item into chassis slot #7 of a 7-slot container. Lithium's mixins only show up in the frame annotations (pl:mixin:APP:lithium.mixins.json:...) because they patch NonNullList/AbstractContainerMenu — the failing write itself is unpatched vanilla logic with no length check.

    The mismatch (from the menu code you attached)

    • Server side, ChassisMenu wraps the live chassis.inventory as the menu container, and that inventory is sized from the chassis config. In our case the power armor frame resolves to 8 slots (part ids 0–7).
    • Client side, PowerArmorMenu's network constructor hard-codes the backing container: new SimpleContainer(SIZE) with SIZE = 7, and createSlots() only adds the 7 armor-part slots — with one of them (fusion core, id 7) landing past the end of that 7-slot container. Meanwhile createSlot silently skips any part whose getId(...) returns null, so the client slot set can also diverge from the server's without any log line.
    • Net effect: the server syncs 8 chassis slots, the client container only has 7, and vanilla's sync has no length validation → the crash you saw.

    Why it looks Lithium-related

    Honestly I'm not 100% sure why your repro needed Lithium — a 7-vs-8 mismatch like this should crash on vanilla too, since broadcastFullState runs on menu open either way. Lithium may only change when the full sync packet gets sent. Worth a quick re-test without it; I suspect it reproduces either way and Lithium just got blamed for being in the stack trace.

    Suggested fix direction (NukaCraft / chassis_core side)

    1. Don't hard-code SIZE = 7 on the client — send the resolved inventory size (or the part→index map) through the FriendlyByteBuf extraData so both sides wrap identically-sized containers, or
    2. Build both menus from the same deterministic part list, and
    3. Log instead of silently skipping in createSlot when a part id is missing.

    Happy to test a dev build — our pack runs NukaCraft 1.19.10-alpha, NTGL 3.2.0, Lithium 0.15.4, NeoForge 21.1.248. Thanks for the great mod!

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

    A-modsT-crash

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions