mirror of
				https://github.com/FaceDeer/dfcaverns.git
				synced 2025-11-04 01:55:28 +01:00 
			
		
		
		
	adding biome API. Not yet tested.
This commit is contained in:
		@@ -41,6 +41,13 @@ local get_biome = function(heat, humidity)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
 | 
			
		||||
	if pos.y < df_caverns.config.level1_min or pos.y > df_caverns.config.ymax then
 | 
			
		||||
		return nil
 | 
			
		||||
	end
 | 
			
		||||
	return get_biome(heat, humidity)	
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
local tower_cap_cavern_floor = function(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
	local ystride = area.ystride
 | 
			
		||||
	if abs_cracks < 0.1 then
 | 
			
		||||
 
 | 
			
		||||
@@ -43,6 +43,13 @@ local get_biome = function(heat, humidity)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
 | 
			
		||||
	if pos.y < df_caverns.config.level2_min or pos.y >= df_caverns.config.level1_min then
 | 
			
		||||
		return nil
 | 
			
		||||
	end
 | 
			
		||||
	return get_biome(heat, humidity)	
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
local goblin_cap_shrublist
 | 
			
		||||
local tunnel_tube_shrublist
 | 
			
		||||
local spore_tree_shrublist
 | 
			
		||||
 
 | 
			
		||||
@@ -36,6 +36,20 @@ local get_biome = function(heat, humidity)
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
 | 
			
		||||
	if pos.y < df_caverns.config.level3_min or pos.y >= df_caverns.config.level2_min then
 | 
			
		||||
		return nil
 | 
			
		||||
	end
 | 
			
		||||
	local biome = get_biome(heat, humidity)
 | 
			
		||||
	if biome == "bloodnether" then
 | 
			
		||||
		if subterrane.get_cavern_value("cavern layer 3", pos) < 0 then
 | 
			
		||||
			return "nethercap"
 | 
			
		||||
		end
 | 
			
		||||
		return "bloodthorn"
 | 
			
		||||
	end
 | 
			
		||||
	return biome
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
local black_cap_shrublist
 | 
			
		||||
local nether_cap_shrublist
 | 
			
		||||
local blood_thorn_shrublist
 | 
			
		||||
 
 | 
			
		||||
@@ -24,6 +24,16 @@ local perlin_wave_primordial = {
 | 
			
		||||
 | 
			
		||||
local giant_mycelium_timer_spread = tonumber(minetest.settings:get("dcaverns_giant_mycelium_timer_spread")) or 10
 | 
			
		||||
 | 
			
		||||
table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
 | 
			
		||||
	if pos.y < df_caverns.config.primordial_min or pos.y > df_caverns.config.primordial_max then
 | 
			
		||||
		return nil
 | 
			
		||||
	end
 | 
			
		||||
	if subterrane.get_cavern_value("primordial", pos) < 0 then
 | 
			
		||||
		return "primordial jungle"
 | 
			
		||||
	end
 | 
			
		||||
	return "primordial fungus"
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
-----------------------------------------------------------------------------------------
 | 
			
		||||
-- Fungal biome
 | 
			
		||||
 | 
			
		||||
@@ -411,7 +421,7 @@ minetest.register_ore({
 | 
			
		||||
	random_factor = 0,
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
-- Rather than make plants farmable, have them randomly respawn in jungle soil. You can only get them down there.
 | 
			
		||||
-- Rather than make plants farmable, have them randomly respawn in jungle soil. You can only get them down there by foraging, not farming.
 | 
			
		||||
minetest.register_abm({
 | 
			
		||||
	label = "Primordial plant growth",
 | 
			
		||||
	nodenames = {"df_primordial_items:dirt_with_jungle_grass"},
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,19 @@ local c_wet_flowstone = df_caverns.node_id.wet_flowstone
 | 
			
		||||
local c_webs = df_caverns.node_id.big_webs
 | 
			
		||||
local c_webs_egg = df_caverns.node_id.big_webs_egg
 | 
			
		||||
 | 
			
		||||
df_caverns.data_param2 = {}
 | 
			
		||||
df_caverns.data_param2 = {} -- shared among all mapgens to reduce memory clutter
 | 
			
		||||
 | 
			
		||||
df_caverns.get_biome_at_pos_list = {} -- a list of methods of the form function(pos, heat, humidity) to allow modpack-wide queries about what should grow where
 | 
			
		||||
df_caverns.get_biome = function(pos)
 | 
			
		||||
	local heat = minetest.get_heat(pos)
 | 
			
		||||
	local humidity = minetest.get_humidity(pos)
 | 
			
		||||
	for _, val in pairs(df_caverns.get_biome_at_pos_list) do
 | 
			
		||||
		local biome = val(pos, heat, humidity)
 | 
			
		||||
		if biome ~= nil then
 | 
			
		||||
			return biome
 | 
			
		||||
		end
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
-- prevent mapgen from using these nodes as a base for stalactites or stalagmites
 | 
			
		||||
local dont_build_speleothems_on = {}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,11 +18,11 @@ for node_name, node_def in pairs(minetest.registered_nodes) do
 | 
			
		||||
	end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
local mushroom_shrublist
 | 
			
		||||
local towergoblin_shrublist
 | 
			
		||||
local fungispore_shrublist
 | 
			
		||||
 | 
			
		||||
if minetest.get_modpath("df_farming") then
 | 
			
		||||
	mushroom_shrublist = {
 | 
			
		||||
	towergoblin_shrublist = {
 | 
			
		||||
		df_farming.spawn_plump_helmet_vm,
 | 
			
		||||
		df_farming.spawn_plump_helmet_vm,
 | 
			
		||||
		df_farming.spawn_dimple_cup_vm,
 | 
			
		||||
@@ -94,7 +94,22 @@ local hot_zone_boundary = 70
 | 
			
		||||
local middle_zone_boundary = 50
 | 
			
		||||
local cool_zone_boundary = 30
 | 
			
		||||
 | 
			
		||||
local mushroom_cavern_floor = function(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
table.insert(df_caverns.get_biome_at_pos_list, function(pos, heat, humidity)
 | 
			
		||||
	if pos.y < df_caverns.config.sunless_sea_min or pos.y >= df_caverns.config.level3_min then
 | 
			
		||||
		return nil
 | 
			
		||||
	end
 | 
			
		||||
	if heat > hot_zone_boundary then
 | 
			
		||||
		return "barren" -- hot zone
 | 
			
		||||
	elseif heat > middle_zone_boundary then
 | 
			
		||||
		return "fungispore"
 | 
			
		||||
	elseif heat > cool_zone_boundary then
 | 
			
		||||
		return "towergoblin"
 | 
			
		||||
	else
 | 
			
		||||
		return "barren" -- cool zone
 | 
			
		||||
	end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
local towergoblin_cavern_floor = function(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
	local ystride = area.ystride
 | 
			
		||||
	if abs_cracks < 0.1 then
 | 
			
		||||
		df_caverns.stalagmites(abs_cracks, vert_rand, vi, area, data, data_param2, true)
 | 
			
		||||
@@ -105,7 +120,7 @@ local mushroom_cavern_floor = function(abs_cracks, vert_rand, vi, area, data, da
 | 
			
		||||
			data[vi] = c_dirt_moss
 | 
			
		||||
		end
 | 
			
		||||
		if math.random() < 0.1 then
 | 
			
		||||
			df_caverns.place_shrub(vi+ystride, area, data, data_param2, mushroom_shrublist)
 | 
			
		||||
			df_caverns.place_shrub(vi+ystride, area, data, data_param2, towergoblin_shrublist)
 | 
			
		||||
		elseif abs_cracks > 0.25 then
 | 
			
		||||
			if math.random() < 0.01 then
 | 
			
		||||
				df_trees.spawn_tower_cap_vm(vi+ystride, area, data)
 | 
			
		||||
@@ -269,7 +284,7 @@ local decorate_sunless_sea = function(minp, maxp, seed, vm, node_arrays, area, d
 | 
			
		||||
				elseif heat > middle_zone_boundary then
 | 
			
		||||
					fungispore_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
				elseif heat > cool_zone_boundary then
 | 
			
		||||
					mushroom_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
					towergoblin_cavern_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
				else
 | 
			
		||||
					cool_zone_floor(abs_cracks, vert_rand, vi, area, data, data_param2)
 | 
			
		||||
				end
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user