Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/basalt.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -1000,
.minHeight = -48250,
.chance = 0.2,
.fogDensity = 8,

Expand Down
3 changes: 1 addition & 2 deletions assets/cubyz/biomes/cave/cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.{
.isCave = true,
.maxHeight = 0,
.minHeight = -48250,
.tags = .{.cave_layer},

.fogDensity = 2,
.caveNoiseStrength = 10,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/crystal.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -512,
.minHeight = -48250,

.chance = 0.2,
.crystals = 32,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/crystal_forest.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -512,
.minHeight = -48250,
.chance = 0.01,

.crystals = 32,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/curl_forest.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -512,
.minHeight = -48250,

.fogDensity = 2,

Expand Down
3 changes: 1 addition & 2 deletions assets/cubyz/biomes/cave/dropoff.zig.zon
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.{
.isCave = true,
.tags = .{.dropoff_layer},
.caveNoiseStrength = 12,

.maxHeight = -48125,
.minHeight = -48500,
.stoneBlock = "cubyz:slate/base",
.fogDensity = 10,
.fogColor = 0x272334,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/ice_cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.caveNoiseStrength = 10,
.maxHeight = -256,
.minHeight = -48250,
.chance = 0.2,
.fogDensity = 20,
.fogColor = 0xbabfbf,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/lava_cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -1500,
.minHeight = -48250,
.fogDensity = 20,
.chance = 0.1,
.fogColor = 0x51240c,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/marble_cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.caveNoiseStrength = 5,
.maxHeight = -64,
.minHeight = -512,
.chance = 0.2,

Expand Down
1 change: 1 addition & 0 deletions assets/cubyz/biomes/cave/mushroom/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.fogDensity = 2,
.music = "cubyz:heart-of-the-beast",
.structures = .{
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/mushroom/big/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -512,
.minHeight = -48250,
.music = "cubyz:la_kubisa_caverna",
.ground_structure = .{
"2 to 3 cubyz:soil",
Expand Down
1 change: 0 additions & 1 deletion assets/cubyz/biomes/cave/mushroom/glimmergill.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.{
.maxHeight = -200,
.minHeight = -48250,
.chance = 0.05,
.structures = .{
.{
Expand Down
1 change: 0 additions & 1 deletion assets/cubyz/biomes/cave/mushroom/toadstool_bolete.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.{
.maxHeight = -64,
.minHeight = -1000,
.chance = 0.3,
.structures = .{
Expand Down
1 change: 1 addition & 0 deletions assets/cubyz/biomes/cave/rare/crying_cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.fogDensity = 8,
.fogColor = 0x3b5c8c,
.chance = 0.01,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/rare/phantasmal.zig.zon
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.fogDensity = 35,
.fogColor = 0x000C14,
.chance = 0.01,
.maxHeight = -5000,
.minHeight = -48250,
.music = "cubyz:cubyz",
.stoneBlock = "cubyz:chalk/black",

Expand Down
3 changes: 1 addition & 2 deletions assets/cubyz/biomes/cave/sky.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.{
.isCave = true,
.minHeight = 0,
.maxHeight = 7000,
.tags = .{.sky_layer},
.caveNoiseStrength = 10,
.music = "cubyz:GymnopedieNo1",

Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/sky_islands/_defaults.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.isCave = true,
.minHeight = 10000,
.tags = .{.sky_island_layer},
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If I were to, by mistake, leave .tags empty, it would be nice to get an error.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Or rather, if I were to not assign a biome to any layer, that might happen even if there are tags

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think there are valid use-cases for having biomes that are not assigned to any layer. An addon may want to add biomes to layers introduced by other addons, while still allowing you to use it standalone.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Well, for that I would say to provide an extra tag .no_cave_layer_required or alike, so we make sure this is not done by mistake.

Btw I assume that biomes which are not part of a cave layer do not generate, right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Either way good catch. I actually did miss some biomes.

I decided to require cave layers to end with _layer, this makes it easy to detect mistakes even when non-layer tags are present.

.fogColor = 0xbbebff,
.fogDensity = 5.0,
.fogLower = 1e10,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/sky_islands/gap.zig.zon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.{
.tags = .{.sky_island_fog_layer},
.chance = 10,
.minHeight = 7000,
}
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/stalagmite_cave.zig.zon
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.caveNoiseStrength = 10,
.maxHeight = -256,
.minHeight = -48250,
.chance = 0.2,

.fogDensity = 10,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/starlit.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.{
.isCave = true,
.tags = .{.cave_layer},
.maxHeight = -10000,
.minHeight = -15000,
.music = "cubyz:heart-of-the-beast",
.chance = 0.1,
.structures = .{
Expand Down
3 changes: 1 addition & 2 deletions assets/cubyz/biomes/cave/stone_forest.zig.zon
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
.{
.isCave = true,
.tags = .{.cave_layer},

.chance = 0.01,
.maxHeight = -50,
.minHeight = -48250,

.music = "cubyz:heart-of-the-beast",

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.{
.isCave = true,
.tags = .{.root_layer},
.fogDensity = 10,
.fogColor = 0x272334,
.maxHeight = -50000,
.music = "cubyz:cubyz",
.stoneBlock = "cubyz:chalk/black",
.chance = 0.01,
Expand Down
3 changes: 1 addition & 2 deletions assets/cubyz/biomes/cave/void/void.zig.zon
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.{
.isCave = true,
.maxHeight = -48500,
.minHeight = -50000,
.tags = .{.void_layer},
.fogDensity = 10,
.fogColor = 0x272334,
.chance = 1,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/void/void_cavern.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.isCave = true,
.maxHeight = -50000,
.tags = .{.root_layer},
.chance = 0.1,
.fogDensity = 10,
.fogColor = 0x272334,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/void/void_crystal.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.isCave = true,
.maxHeight = -50000,
.tags = .{.root_layer},
.fogDensity = 10,
.fogColor = 0x272334,
.chance = 0.01,
Expand Down
2 changes: 1 addition & 1 deletion assets/cubyz/biomes/cave/void/void_roots.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.isCave = true,
.maxHeight = -50000,
.tags = .{.root_layer},
.fogDensity = 10,
.fogColor = 0x272334,
.chance = 1,
Expand Down
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/caves.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.cave_layer},
.layerHeight = 48250,
.depthHint = -1,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/dropoff.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.dropoff_layer},
.layerHeight = 250,
.depthHint = -48250,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/sky.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.sky_layer},
.layerHeight = 7000,
.depthHint = 0,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/sky_island_fog.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.sky_island_fog_layer},
.layerHeight = 3000,
.depthHint = 7000,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/sky_islands.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.sky_island_layer},
.layerHeight = 10000,
.depthHint = 10000,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/void.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.void_layer},
.layerHeight = 1500,
.depthHint = -48500,
}
5 changes: 5 additions & 0 deletions assets/cubyz/cave_layers/void_roots.zig.zon
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.{
.tags = .{.root_layer},
.layerHeight = 10000,
.depthHint = -50000,
}
13 changes: 11 additions & 2 deletions src/assets.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub const Assets = struct {
tools: ZonHashMap,
biomes: ZonHashMap,
biomeMigrations: AddonNameToZonMap,
caveLayers: ZonHashMap,
entityComponents: ZonHashMap,
entityComponentMigrations: AddonNameToZonMap,
structureTables: ZonHashMap,
Expand All @@ -50,6 +51,7 @@ pub const Assets = struct {
.tools = .{},
.biomes = .{},
.biomeMigrations = .{},
.caveLayers = .{},
.entityComponents = .{},
.entityComponentMigrations = .{},
.structureTables = .{},
Expand All @@ -71,6 +73,7 @@ pub const Assets = struct {
self.tools.deinit(allocator.allocator);
self.biomes.deinit(allocator.allocator);
self.biomeMigrations.deinit(allocator.allocator);
self.caveLayers.deinit(allocator.allocator);
self.entityComponents.deinit(allocator.allocator);
self.entityComponentMigrations.deinit(allocator.allocator);
self.structureTables.deinit(allocator.allocator);
Expand All @@ -92,6 +95,7 @@ pub const Assets = struct {
.tools = self.tools.clone(allocator.allocator) catch unreachable,
.biomes = self.biomes.clone(allocator.allocator) catch unreachable,
.biomeMigrations = self.biomeMigrations.clone(allocator.allocator) catch unreachable,
.caveLayers = self.caveLayers.clone(allocator.allocator) catch unreachable,
.entityComponents = self.entityComponents.clone(allocator.allocator) catch unreachable,
.entityComponentMigrations = self.entityComponentMigrations.clone(allocator.allocator) catch unreachable,
.structureTables = self.structureTables.clone(allocator.allocator) catch unreachable,
Expand All @@ -116,6 +120,7 @@ pub const Assets = struct {
addon.readAllZon(allocator, "tools", true, &self.tools, null);
addon.readAllZon(allocator, "structure_tables", false, &self.structureTables, null);
addon.readAllZon(allocator, "biomes", true, &self.biomes, &self.biomeMigrations);
addon.readAllZon(allocator, "cave_layers", true, &self.caveLayers, null);
addon.readAllZon(allocator, "recipes", false, &self.recipes, null);
addon.readAllZon(allocator, "sbb", true, &self.structureBuildingBlocks, null);
addon.readAllBlueprints(allocator, "sbb", &self.blueprints);
Expand All @@ -128,8 +133,8 @@ pub const Assets = struct {
}
fn log(self: *Assets, typ: enum { common, world }) void {
std.log.info(
"Finished {s} assets reading with {} blocks, {} items, {} tools, {} biomes, {} structure tables, {} recipes, {} structure building blocks, {} blueprints, {} particles, and {} world presets",
.{@tagName(typ), self.blocks.count(), self.items.count(), self.tools.count(), self.biomes.count(), self.structureTables.count(), self.recipes.count(), self.structureBuildingBlocks.count(), self.blueprints.count(), self.particles.count(), self.worldPresets.count()},
"Finished {s} assets reading with {} blocks, {} items, {} tools, {} biomes, {} cave layers, {} structure tables, {} recipes, {} structure building blocks, {} blueprints, {} particles, and {} world presets",
.{@tagName(typ), self.blocks.count(), self.items.count(), self.tools.count(), self.biomes.count(), self.caveLayers.count(), self.structureTables.count(), self.recipes.count(), self.structureBuildingBlocks.count(), self.blueprints.count(), self.particles.count(), self.worldPresets.count()},
);
}

Expand Down Expand Up @@ -697,6 +702,9 @@ pub fn loadWorldAssets(assetFolder: []const u8, blockPalette: *Palette, itemPale
}
biomes_zig.finishLoading();

// Cave layers:
try main.server.terrain.cave_layers.registerCaveLayers(&worldAssets.caveLayers);

// EntityComponents
{
var map: std.StringHashMap(u32) = .init(main.stackAllocator.allocator);
Expand Down Expand Up @@ -757,6 +765,7 @@ pub fn unloadAssets() void { // MARK: unloadAssets()
items_zig.reset();
migrations_zig.reset();
biomes_zig.reset();
main.server.terrain.cave_layers.reset();
migrations_zig.reset();
main.server.terrain.structures.reset();
main.models.reset();
Expand Down
9 changes: 8 additions & 1 deletion src/server/terrain/biomes.zig
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,13 @@ pub const Biome = struct { // MARK: Biome
.maxSubBiomeCount = zon.get(f32, "maxSubBiomeCount", std.math.floatMax(f32)),
.tags = Tag.loadTagsFromZon(main.worldArena, zon.getChild("tags")),
};
if (self.isCave) {
for (self.tags) |tag| {
if (std.mem.endsWith(u8, tag.getName(), "_layer")) break;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Okay, but do we reserve a no_layer or similar tag for marking the biomes explicitly unassigned?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No, There is currently no reason to have an unassigned cave biome, since it wouldn't spawn under any circumstances. If you want to temporarily disable a biome you can also set the chance to 0.

} else {
std.log.err("Cave biome {s} is missing a '_layer' tag to assign it to a cave layer.", .{id});
}
}
if (minRadius > maxRadius) {
std.log.err("Biome {s} has invalid radius range ({d}, {d})", .{self.id, minRadius, maxRadius});
}
Expand Down Expand Up @@ -382,7 +389,7 @@ pub const Biome = struct { // MARK: Biome
return hashGeneric(self.*);
}

fn hasTag(self: Biome, tag: Tag) bool {
pub fn hasTag(self: Biome, tag: Tag) bool {
return std.mem.containsAtLeastScalar(Tag, self.tags, 1, tag);
}
};
Expand Down
Loading
Loading