Skip to content

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 biomeTags (new feature, currently unused) against the biomeTags in each structure table that was loaded previously. If any biomeTags match, add the structures from those tables into the biome's internal structure table in memory at world load time.

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

Implementation details:

Moved hashing functions out of src/server/terrain/biomes.zig into src/utils/hash.zig
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
.tools = .{},
.biomes = .{},
.biomeMigrations = .{},
.structureTables = .{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of adding a new asset type, why not just add the structures directly to the biomes when loading the structure table?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess that could work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm investigating this a little and it might be easiest to use the approach I took with a new asset type.

At least this way we can have assets load in the structure tables and have a place to put them.
Otherwise, I'm not sure how you'd load structure tables without adding another way to load assets that isn't the standard flow in assets.zig, which may not be preferable due to diverging ways to load assets.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just put this directly into utils.zig? It's small enough that it doesn't need its own file.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moving this to a new file should probably be in a separate PR, it make the diff hard to read.

Copy link
Contributor Author

@BoySanic BoySanic Oct 25, 2025

Choose a reason for hiding this comment

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

I have a single commit for this that I can cherrypick and PR separately before we tackle this one.

If that's preferred I can split that out and PR it on its own to simplify this PR (for when it's no longer a draft)

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, definitely. Quantum doesn't like multiple less related changes in one PR (I don't either)

@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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Biome independent structure table

2 participants