Improve cactus drops and spawning (#4581)

- breaking cactus will drop randomly in x=-0.75..+0.75, z=-0.75..+0.75
- breaking cactus will have an initial velocity in this direction
- if a larger cactus break, they break into the same direction
- cactus growth rate reduced 4x, to debuff farm efficiency (will need a larger rebalancing)
- cactus only spawns when there is air surrounding it and above, so it does not immediately break
- slightly increase the frequency of cactus to counter this

The first changes make cactus farms possible.

Reviewed-on: VoxeLibre/VoxeLibre#4581
Reviewed-by: Mikita Wiśniewski <rudzik8@protonmail.com>
Co-authored-by: kno10 <erich.schubert@gmail.com>
Co-committed-by: kno10 <erich.schubert@gmail.com>
This commit is contained in:
kno10 2024-08-30 18:22:05 +02:00 committed by the-real-herowl
parent d2b96b6142
commit 8fd736e0fd
2 changed files with 25 additions and 15 deletions

View File

@ -191,12 +191,16 @@ minetest.register_abm({
nodenames = {"mcl_core:cactus"},
neighbors = {"group:sand"},
interval = 25,
chance = 10,
chance = 40,
action = function(pos)
mcl_core.grow_cactus(pos)
end,
})
local function is_walkable(pos)
local ndef = minetest.registered_nodes[minetest.get_node(pos).name]
return ndef and ndef.walkable
end
minetest.register_abm({
label = "Cactus mechanisms",
nodenames = {"mcl_core:cactus"},
@ -209,18 +213,21 @@ minetest.register_abm({
object:remove()
end
end
local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
for _, p in pairs(posses) do
local ndef = minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name]
if ndef and ndef.walkable then
local posy = pos.y
while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do
local pos = vector.new(pos.x, posy, pos.z)
minetest.dig_node(pos)
-- minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus")
posy = posy + 1
end
break
if is_walkable(vector.offset(pos, 1, 0, 0))
or is_walkable(vector.offset(pos, -1, 0, 0))
or is_walkable(vector.offset(pos, 0, 0, 1))
or is_walkable(vector.offset(pos, 0, 0, -1)) then
local lpos = vector.copy(pos)
local dx, dy
while true do
local node = minetest.get_node(lpos)
if not node or node.name ~= "mcl_core:cactus" then break end
minetest.dig_node(lpos)
dx = dx or ((math.random(0,1)-0.5) * math.sqrt(math.random())) * 1.5
dy = dy or ((math.random(0,1)-0.5) * math.sqrt(math.random())) * 1.5
local obj = minetest.add_item(vector.offset(lpos, dx, 0.25, dy), "mcl_core:cactus")
obj:set_velocity(vector.new(dx, 1, dy))
lpos.y = lpos.y + 1
end
end
end,

View File

@ -4656,9 +4656,9 @@ local function register_decorations()
place_on = {"group:sand"},
sidelen = 16,
noise_params = {
offset = -0.012,
offset = -0.01,
scale = 0.024,
spread = {x = 100, y = 100, z = 100},
spread = vector.new(100, 100, 100),
seed = 257,
octaves = 3,
persist = 0.6
@ -4672,6 +4672,9 @@ local function register_decorations()
"MesaPlateauFM", "MesaPlateauFM_sandlevel"},
height = 1,
height_max = 3,
spawn_by = "air",
check_offset = 1,
num_spawn_by = 16
})
-- Sugar canes