Skip to content
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

Only remove worldgen block entity on changed block #10794

Merged
merged 2 commits into from
May 28, 2024

Conversation

lynxplay
Copy link
Contributor

The previous PR #10375 removes block entities on setBlock calls to the WorldGen region to prevent the existence of a block entity on a block that does not support it as such.

The logic however assumed that such calls would always follow the order of:

  1. set the base blockstate
  2. create the block entity
  3. finish world gen

This is however not the case for all of world gen, specifically not for structure templates being placed under water, as these first set the block state, then configure its block entity (include the chests lootable) and finally waterlogs the chest by calling another setBlock.

To prevent this logic from deleting the original block entity, this commit now only removes the block entity found if the blockstate to be set differs from the previous one, matching LevelChunk#setBlockState.

Supersedes: #10768
Fixes: #10750

Copy link
Member

@kennytv kennytv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

obfhelpers might be nice

@lynxplay
Copy link
Contributor Author

obfhelper added.

@kennytv kennytv added the priority: high This issue is either a gamebreaking bug or crash and needs to be addressed soon. label May 27, 2024
The previous PR PaperMC#10375 removes block entities on setBlock calls to the
WorldGen region to prevent the existence of a block entity on a block
that does not support it as such.

The logic however assumed that such calls would always follow the order
of:
  1. set the base blockstate
  2. create the block entity
  3. finish world gen

This is however not the case for all of world gen, specifically not for
structure templates being placed under water, as these first set the
block state, then configure its block entity (include the chests
lootable) and finally waterlogs the chest by calling another setBlock.

To prevent this logic from deleting the original block entity, this
commit now only removes the block entity found if the blockstate to be
set differs from the previous one, matching LevelChunk#setBlockState.
@lynxplay lynxplay force-pushed the bugfix/invalid-block-entities-v2 branch from d7e3575 to 089396e Compare May 27, 2024 18:37
@kennytv kennytv merged commit b0c9b9c into PaperMC:master May 28, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high This issue is either a gamebreaking bug or crash and needs to be addressed soon.
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

Underwater ruined portal chests don't spawn loot.
3 participants