Add ice spikes for v6

This commit is contained in:
kay27 2022-01-19 03:41:22 +04:00
parent 6ac682fdcf
commit 4a3f1032ca
10 changed files with 133 additions and 15 deletions

View File

@ -168,7 +168,6 @@ mcl_structures.register_structure({
end
end
end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,

View File

@ -87,7 +87,6 @@ mcl_structures.register_structure({
end
end
end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,

View File

@ -0,0 +1,66 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local chance_per_chunk = 5
local random_offset = 24435
local struct_threshold = chance_per_chunk - 1
local noise_params = {
offset = 0,
scale = 1,
spread = {
x = 1000,
y = 1000,
z = 1000,
},
scale = 0.01,
seed = 29313,
octaves = 2,
persistence = 0.7,
}
local node_list = {"mcl_core:snowblock", "mcl_core:dirt_with_grass_snow"}
local schematic = modpath.."/schematics/mcl_structures_ice_spike_large.mts"
minetest_find_nodes_in_area = minetest.find_nodes_in_area
local function place(pos, rotation, pr)
mcl_structures.place_schematic({pos = pos, schematic = schematic, rotation = rotation, pr = pr})
end
local function is_place_ok(p)
-- Check surface
local floor = {x=p.x+4, y=p.y-1, z=p.z+4}
local surface = #minetest_find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, node_list, false)
if surface < 9 then return end
-- Check for collision with spruce
local spruce_collisions = #minetest_find_nodes_in_area({x=p.x+1,y=p.y+2,z=p.z+1}, {x=p.x+4, y=p.y+6, z=p.z+4}, {"group:tree"}, false)
if spruce_collisions > 0 then return end
return true
end
local def = mcl_mapgen.v6 and {
decoration = {
deco_type = "simple",
place_on = node_list,
noise_params = noise_params,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_mapgen.overworld.max,
height = 1,
},
on_finished_chunk = mcl_mapgen.v6 and function(minp, maxp, seed, vm_context, pos_list)
local pr = PseudoRandom(seed + random_offset)
local random_number = pr:next(1, chance_per_chunk)
if random_number < struct_threshold then return end
for i = 1, #pos_list do
local pos = pos_list[i]
if is_place_ok(pos) then
place(pos, nil, pr)
end
end
end,
} or {}
def.name = "ice_spike_large"
def.place_function = place
mcl_structures.register_structure(def)

View File

@ -0,0 +1,65 @@
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
local chance_per_chunk = 3
local random_offset = 1264
local struct_threshold = chance_per_chunk - 1
local noise_params = {
offset = 0,
scale = 1,
spread = {
x = mcl_mapgen.CS,
y = mcl_mapgen.CS,
z = mcl_mapgen.CS,
},
scale = 0.3,
seed = 32931,
octaves = 2,
persistence = 0.7,
}
local node_list = {"mcl_core:snowblock", "mcl_core:dirt_with_grass_snow"}
local schematic = modpath.."/schematics/mcl_structures_ice_spike_small.mts"
minetest_find_nodes_in_area = minetest.find_nodes_in_area
local function place(pos, rotation, pr)
mcl_structures.place_schematic({pos = pos, schematic = schematic, rotation = rotation, pr = pr})
end
local function is_place_ok(p)
local floor = {x=p.x+6, y=p.y-1, z=p.z+6}
local surface = #minetest_find_nodes_in_area({x=p.x+1,y=p.y-1,z=p.z+1}, floor, node_list, false)
if surface < 25 then return end
-- Check for collision with spruce
local spruce_collisions = #minetest_find_nodes_in_area({x=p.x+1,y=p.y+1,z=p.z+1}, {x=p.x+6, y=p.y+6, z=p.z+6}, {"group:tree"}, false)
if spruce_collisions > 0 then return end
return true
end
local def = mcl_mapgen.v6 and {
decoration = {
deco_type = "simple",
place_on = node_list,
noise_params = noise_params,
y_min = mcl_mapgen.overworld.min,
y_max = mcl_mapgen.overworld.max,
height = 1,
},
on_finished_chunk = mcl_mapgen.v6 and function(minp, maxp, seed, vm_context, pos_list)
local pr = PseudoRandom(seed + random_offset)
local random_number = pr:next(1, chance_per_chunk)
if random_number < struct_threshold then return end
for i = 1, #pos_list do
local pos = pos_list[i]
if is_place_ok(pos) then
place(pos, nil, pr)
end
end
end,
} or {}
def.name = "ice_spike_small"
def.place_function = place
mcl_structures.register_structure(def)

View File

@ -189,7 +189,6 @@ mcl_structures.register_structure({
end
end
if count < 0 then return end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,

View File

@ -339,10 +339,6 @@ function mcl_structures.call_struct(pos, struct_style, rotation, pr, callback)
end
if struct_style == "witch_hut" then
return mcl_structures.generate_witch_hut(pos, rotation)
elseif struct_style == "ice_spike_small" then
return mcl_structures.generate_ice_spike_small(pos, rotation)
elseif struct_style == "ice_spike_large" then
return mcl_structures.generate_ice_spike_large(pos, rotation)
elseif struct_style == "boulder" then
return mcl_structures.generate_boulder(pos, rotation, pr)
elseif struct_style == "end_exit_portal" then
@ -405,11 +401,6 @@ function mcl_structures.generate_witch_hut(pos, rotation, pr)
mcl_structures.place_schematic(pos, path, rotation, nil, true, nil, hut_placement_callback, pr)
end
function mcl_structures.generate_ice_spike_small(pos, rotation)
local path = modpath.."/schematics/mcl_structures_ice_spike_small.mts"
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0
end
function mcl_structures.generate_ice_spike_large(pos, rotation)
local path = modpath.."/schematics/mcl_structures_ice_spike_large.mts"
return minetest.place_schematic(pos, path, rotation or "random", nil, false) -- don't serialize schematics for registered biome decorations, for MT 5.4.0

View File

@ -197,7 +197,6 @@ mcl_structures.register_structure({
end
end
if count < 0 then return end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,

View File

@ -203,7 +203,6 @@ mcl_structures.register_structure({
end
end
if count < 0 then return end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,

View File

@ -6,6 +6,8 @@ if not mcl_mapgen.singlenode then
dofile(modpath .. "/desert_well.lua")
dofile(modpath .. "/fossil.lua")
dofile(modpath .. "/igloo.lua")
dofile(modpath .. "/ice_spike_small.lua")
dofile(modpath .. "/ice_spike_large.lua")
dofile(modpath .. "/jungle_temple.lua")
dofile(modpath .. "/nice_jungle_temple.lua")
dofile(modpath .. "/noise_indicator.lua")

View File

@ -130,7 +130,6 @@ mcl_structures.register_structure({
end
end
end
local pr = PseudoRandom(vm_context.chunkseed)
place(pos, nil, pr)
end,
place_function = place,