Skip to content

Biome-independent structure tables#2129

Open
BoySanic wants to merge 36 commits intoPixelGuys:masterfrom
BoySanic:fix/1805
Open

Biome-independent structure tables#2129
BoySanic wants to merge 36 commits intoPixelGuys:masterfrom
BoySanic:fix/1805

Conversation

@BoySanic
Copy link
Contributor

@BoySanic BoySanic commented Oct 24, 2025

Fixes #1805
Implements biome-independent structure tables.

The way these work:

Structure tables are loaded into the game along with all other assets.
When loading biomes, each biome checks its tags (new feature, currently unused) against the tags in each structure table that was loaded previously. If all tags on the table have matches in the biome's tags, add the structures from that table into the biome's internal structure table in memory at world load time.

Additionally, if a structure table has an empty .tags (len == 0), it should spawn those structures in all biomes. So those structures are added to all biomes' internal structure table.

Implementation details:

Moved SimpleStructureModel into src/server/terrain/structures.zig from src/server/terrain/biomes.zig.

Example structure table .zig.zon in assets/cubyz/structure_tables in this branch.

@BoySanic BoySanic changed the title Fix/1805 Biome-independent structure tables Oct 25, 2025
@BoySanic
Copy link
Contributor Author

On the topic of this PR, I was thinking about how addons might target biomes and with the current approach they'd use biome tags.

I think it may make sense to allow the structure table to use the biome's id as a tag, too. Just check if the structure table's biomeTags contains the biome's Id (it would just be an or on the current check that is used) and it'd make that easier. Then we don't have to come up with tags to target specific biomes, we just use their id as a tag logically.

In the future I envision we start categorizing biomes. like cubyz:cold, cubyz:humid, cubyz:dry, cubyz:hot, and so on for the various "tags" that could apply to a biome. Then, similar to the #1805 example, maybe an addon that adds igloos would create a structure table containing that igloo and it would set its biomeTags to cubyz:cold or something, so the igloos are added to biomes that are tagged cubyz:cold.

@BoySanic BoySanic moved this to WIP/not ready for review in PRs to review Nov 3, 2025
This was referenced Nov 3, 2025
@BoySanic BoySanic closed this Nov 7, 2025
@BoySanic BoySanic deleted the fix/1805 branch November 7, 2025 22:09
@BoySanic BoySanic restored the fix/1805 branch November 7, 2025 22:35
@BoySanic
Copy link
Contributor Author

BoySanic commented Nov 7, 2025

I didn't mean to close that

@BoySanic BoySanic reopened this Nov 7, 2025
IntegratedQuantum pushed a commit that referenced this pull request Feb 25, 2026
This PR splits out structures and hashing from biomes.zig into
structures.zig and src/utils.zig respectively.

This change should be done for the following reasons:

1. It cleans up #2129. A lot.
2. Splitting it out from biomes.zig into another file makes it a bit
cleaner once we add the changes from #2129 that introduces the
StructureTable struct for example. It's technically feasible to leave it
all in biomes.zig, splitting it out made the most sense to me at the
time for organization purposes.
@BoySanic BoySanic marked this pull request as ready for review February 25, 2026 17:58
@BoySanic BoySanic moved this from WIP/not ready for review to High Priority in PRs to review Feb 25, 2026
@BoySanic
Copy link
Contributor Author

Memory leak fixed, and I added migrations stuff to it for whenever someone needs to migrate structure_tables in the future. This should be good to go for review.

@BoySanic
Copy link
Contributor Author

Whenever this is merged, #1283 can proceed as meteorites can be made into a structure table that spawns in any biome or biomes with specific tags. (Biomes currently have no tags, but coming up with those tags could be an issue on its own to discuss)

@BoySanic BoySanic mentioned this pull request Feb 26, 2026
@IntegratedQuantum
Copy link
Member

It'd also be good to have a configurable radius so structures don't spawn too close to each other.

There is a limit of a few blocks. Anything beyond that is not possible with the current, precomputed, blue noise map.

@BoySanic
Copy link
Contributor Author

BoySanic commented Mar 10, 2026

Hmm, maybe if a structure table had a .chance which itself multiplies each structure's chance in the table?

Yes, that would also be useful, but my proposal is different: limiting the total chance. This would make it easier to add structure variants without having to adjust the chance every time you add a new one. Like if I add a second meteor variant, I don't want meteors to be twice as common in the world.

Hmm, I see.

Should individual structure chances be normalized to fractions of the total chance on the full table?

(Like how we do structures in a biome right now, but instead of checking > 1, check > totalChance, and normalize so when summed they equal totalChance)

@IntegratedQuantum
Copy link
Member

IntegratedQuantum commented Mar 10, 2026

yes, though unlike biomes I'd say if present, it should always normalize to that value, even if it's below it.

@BoySanic
Copy link
Contributor Author

I'm not entirely sure I got it right, but I implemented it

Copy link
Member

@IntegratedQuantum IntegratedQuantum left a comment

Choose a reason for hiding this comment

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

Also there are still traces of #2129 (comment)

Furthermore I want the structure table for that unique and never seen before structure from ikabod.

@BoySanic
Copy link
Contributor Author

I'll remove the "torches_everywhere" and "meme" structure tables now that we have a real one added.

@IntegratedQuantum
Copy link
Member

please fix the errors

@BoySanic
Copy link
Contributor Author

Should be good to go

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

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

Biome independent structure table

5 participants