Skip to content

Add BiomeProvider structure search fast path to CustomWorldChunkManager#13836

Open
diytechy wants to merge 1 commit intoPaperMC:mainfrom
diytechy:FEATURE_BiomeProvider-structure-search
Open

Add BiomeProvider structure search fast path to CustomWorldChunkManager#13836
diytechy wants to merge 1 commit intoPaperMC:mainfrom
diytechy:FEATURE_BiomeProvider-structure-search

Conversation

@diytechy
Copy link
Copy Markdown

Adds getStructurePlacementBiome(WorldInfo, int, int) to the Bukkit BiomeProvider API as a default method returning Optional.empty(). Generators may override this to return a cheap 2D biome approximation for structure placement eligibility checks (e.g. land vs ocean for stronghold ring position computation), bypassing expensive 3D pipeline evaluation for standard terrain generation.

CustomWorldChunkManager overrides findBiomeHorizontal, setting a ThreadLocal flag while the search runs so getNoiseBiome can call getStructurePlacementBiome() instead of the full getBiome() path. This avoids the extensive pipeline calculation cost for biome placement in more complex terrain generators like Terra.

Falls back silently to getBiome() if the provider returns empty, CraftBiome.bukkitToMinecraftHolder returns null, or the generator does not implement getStructurePlacementBiome.

Includes one-shot diagnostic logging to confirm the fast path is active and being used during stronghold searches.

Adds getStructurePlacementBiome(WorldInfo, int, int) to the Bukkit
BiomeProvider API as a default method returning Optional.empty().
Generators may override this to return a cheap 2D biome approximation
for structure placement eligibility checks (e.g. land vs ocean for
stronghold ring position computation), bypassing expensive 3D pipeline
evaluation for standard terrain generation.

CustomWorldChunkManager overrides findBiomeHorizontal, setting a
ThreadLocal flag while the search runs so getNoiseBiome can call
getStructurePlacementBiome() instead of the full getBiome() path.
This avoids the extensive pipeline calculation cost for biome placement
in more complex terrain generators like Terra.

Falls back silently to getBiome() if the provider returns empty,
CraftBiome.bukkitToMinecraftHolder returns null, or the generator
does not implement getStructurePlacementBiome.

Includes one-shot diagnostic logging to confirm the fast path is
active and being used during stronghold searches.
@diytechy diytechy requested a review from a team as a code owner April 28, 2026 11:19
@github-project-automation github-project-automation Bot moved this to Awaiting review in Paper PR Queue Apr 28, 2026
@kennytv
Copy link
Copy Markdown
Member

kennytv commented Apr 29, 2026

Do you need the debug logging or was it more for initial confirmation that it works? otherwise I'd just remove it since it ends up being more atomic logging code than implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Awaiting review

Development

Successfully merging this pull request may close these issues.

2 participants