Skip to content

[1.21.5] Crash when trying to save world with chunks forceloaded through NeoForge #2115

Open
@RedstoneDubstep

Description

@RedstoneDubstep

Minecraft Version: 1.21.5

**NeoForge Version:**21.5.14-beta

Logs: Crash report https://pastebin.com/87ZLwbQ9

Steps to Reproduce:

  1. Create a new singleplayer world
  2. Through a custom mod/test mod, request any chunk using NeoForge's TicketController for a BlockPos owner or an Entity owner. I did this the following way: SecurityCraft.CAMERA_TICKET_CONTROLLER.forceChunk(serverLevel, dummyEntity, x, z, true, false); with dummyEntity being of type SecurityCamera.
  3. Allow your world to save, either by entering the pause menu or waiting until the world autosaves.
  4. Observe the game crashing

Description of issue:
As discussed in Discord, the issue is NeoForge's ForcedChunkManager trying to encode its chunks in vanilla's TicketStorage (see TicketStorage#37), and using a custom codec to do so. This codec effectively tries to save a Map<UUID, TicketSet> and a Map<BlockPos, TicketSet> to NBT, for storage within the world data file. However, for the Java maps to be properly convertible to a CompoundTag for storage, both key entries (BlockPos and UUID) need to be serialized to a String, which is not happening currently due to the wrong codecs being used (they're currently both converted to an IntStream, which CompoundTag cannot deal with). This leads the game to crash since the ForcedChunkManager data cannot be saved to NBT.

Relevant Discord conversation with potential suggestions: https://discord.com/channels/313125603924639766/852298000042164244/1357804883260084395

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds triaging and confirmation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions