Skip to content

Fix unloaded postbox voiding packages #8553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: mc1.20.1/dev
Choose a base branch
from

Conversation

danth
Copy link
Contributor

@danth danth commented May 25, 2025

There seems to be an area of chunks where Level.isLoaded returns false, but PostboxBlockEntity.onChunkUnloaded has not yet been called. Any trains delivering to that area will use the offline buffer, but when the block entity is eventually unloaded, it will overwrite the delivered packages with an older version of the inventory, causing them to be lost.

I made the following changes to fix this:

  • Sync the offline buffer whenever the inventory changes, rather than in onChunkUnloaded.
  • Fix StationBlockEntity.attachPackagePort incorrectly replacing GlobalPackagePort instances with new ones, resetting their data.
  • During mail transfer, get the Level from ServerLifecycleHooks rather than CarriageContraptionEntity: this ensures a loaded postbox will always be discovered, regardless of whether the train itself is loaded.

Fixes #7491 (see my comment there for how to reproduce the bug)

There seems to be an area of chunks where `Level.isLoaded` returns
`false`, but `PostboxBlockEntity.onChunkUnloaded` has not yet been
called. Any trains delivering to that area will use the offline buffer,
but when the block entity is eventually unloaded, it will overwrite the
delivered packages with an older version of the inventory, causing them
to be lost.

I made the following changes to fix this:

- Sync the offline buffer whenever the inventory changes, rather than
  in `onChunkUnloaded`.
- Fix `StationBlockEntity.attachPackagePort` incorrectly replacing
  `GlobalPackagePort` instances with new ones, resetting their data.
- During mail transfer, get the `Level` from `ServerLifecycleHooks`
  rather than `CarriageContraptionEntity`: this ensures a loaded
  postbox will always be discovered, regardless of whether the train
  itself is loaded.

Fixes Creators-of-Create#7491
@IThundxr IThundxr added the pr type: fix PR fixes a bug label May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr type: fix PR fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Packages are voided instead of being placed in unloaded postboxes
2 participants