Skip to content

Chunk lifecycle events with chunk systems that replace vanilla's (e.g. Moonrise) #302

Open

Description

@jpenilla

FFAPI fires ServerChunkEvents.CHUNK_LOAD, CHUNK_GENERATE, CHUNK_UNLOAD and FULL_CHUNK_STATUS_CHANGE from mixins into vanilla ChunkStatusTasks.full, ChunkMap.scheduleUnload and ChunkHolder.updateFutures. Moonrise replaces those code paths, so with Moonrise installed none of these events fire, and LoadedChunksCache stays empty (Tuinity/Moonrise#210). Moonrise does post NeoForge's ChunkEvent.Load/Unload.

On Fabric, Moonrise fires the Fabric API events itself. On NeoForge we're unsure where this should live. If Moonrise fires FFAPI's events and FFAPI later starts translating NeoForge's chunk events, everything would fire twice. If FFAPI translates NeoForge's events, the timing changes slightly: on plain NeoForge, ChunkEvent.Unload is posted after the chunk is saved, while Fabric API's CHUNK_UNLOAD fires before it. FULL_CHUNK_STATUS_CHANGE has no NeoForge equivalent either way.

How would you prefer to handle this, so these events work with other chunk systems without risking double dispatch?

Activity

  1. cassiancc commented on Oct 31, 2026

    @cassiancc
    Contributor

    C2ME's developer has already requested that FFAPI fire these events from NeoForge's events, and was recommended to make a PR to implement this. That seems like the most reasonable option to me.

  2. jpenilla commented on Oct 31, 2026

    @jpenilla
    ContributorAuthor

    The main thing to consider is if the unload timing change is acceptable; it seems like it could lead to data loss. NeoForge firing unload after save is acceptable in their API as they have a separate save event.

  3. jpenilla commented on Nov 1, 2026

    @jpenilla
    ContributorAuthor

    I looked for mods that would be affected by the unload timing change. Of the public code GitHub search covers (316 CHUNK_UNLOAD listeners and 152 BLOCK_ENTITY_UNLOAD listeners), almost all only clear their own caches or trackers, or save to separate storage. The only one I found that relies on CHUNK_UNLOAD running before the chunk is saved is SteamCraft, which re-sets a chunk attachment there so recent changes get saved. Fabric API doesn't document that ordering either, so the impact looks small in practice.

  4. cassiancc commented on Nov 1, 2026

    @cassiancc
    Contributor

    Steamcraft is also only on 1.21.1 - which versions were you looking to make this change on?

  5. jpenilla commented on Nov 1, 2026

    @jpenilla
    ContributorAuthor

    Moonrise currently support 26.1.2 (anticipated Neo LTS) and 26.3. So in that case I can open a PR shortly.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions