Refactor plant growth, improve bone meal on plants
This commit is contained in:
parent
a7504781c4
commit
d3e2a21d5f
8 changed files with 76 additions and 94 deletions
|
@ -103,7 +103,7 @@ minetest.register_node("mcl_farming:beetroot", {
|
|||
{-0.5, -0.5, -0.5, 0.5, -0.125, 0.5}
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1,dig_by_water=1,dig_by_piston=1},
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1,dig_by_water=1,dig_by_piston=1,beetroot=4},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
_mcl_blast_resistance = 0,
|
||||
})
|
||||
|
@ -139,7 +139,7 @@ minetest.register_craft({
|
|||
},
|
||||
})
|
||||
|
||||
mcl_farming:add_plant("mcl_farming:beetroot", {"mcl_farming:beetroot_0", "mcl_farming:beetroot_1", "mcl_farming:beetroot_2"}, 68, 3)
|
||||
mcl_farming:add_plant("plant_beetroot", "mcl_farming:beetroot", {"mcl_farming:beetroot_0", "mcl_farming:beetroot_1", "mcl_farming:beetroot_2"}, 68, 3)
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
for i=1,2 do
|
||||
|
|
|
@ -124,7 +124,7 @@ minetest.register_craft({
|
|||
}
|
||||
})
|
||||
|
||||
mcl_farming:add_plant("mcl_farming:carrot", {"mcl_farming:carrot_1", "mcl_farming:carrot_2", "mcl_farming:carrot_3"}, 50, 20)
|
||||
mcl_farming:add_plant("plant_carrot", "mcl_farming:carrot", {"mcl_farming:carrot_1", "mcl_farming:carrot_2", "mcl_farming:carrot_3"}, 50, 20)
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
for i=2,3 do
|
||||
|
|
|
@ -84,7 +84,7 @@ for s=1,7 do
|
|||
{-0.15, -0.5, -0.15, 0.15, -0.5+h, 0.15}
|
||||
},
|
||||
},
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1, attached_node=1, dig_by_water=1},
|
||||
groups = {dig_immediate=3, not_in_creative_inventory=1, attached_node=1, dig_by_water=1, plant_melon_stem=s},
|
||||
sounds = mcl_sounds.node_sound_leaves_defaults(),
|
||||
_mcl_blast_resistance = 0,
|
||||
})
|
||||
|
@ -99,7 +99,7 @@ local stem_def = {
|
|||
}
|
||||
|
||||
-- Register stem growth
|
||||
mcl_farming:add_plant("mcl_farming:melontige_unconnect", {"mcl_farming:melontige_1", "mcl_farming:melontige_2", "mcl_farming:melontige_3", "mcl_farming:melontige_4", "mcl_farming:melontige_5", "mcl_farming:melontige_6", "mcl_farming:melontige_7"}, 30, 5)
|
||||
mcl_farming:add_plant("plant_melon_stem", "mcl_farming:melontige_unconnect", {"mcl_farming:melontige_1", "mcl_farming:melontige_2", "mcl_farming:melontige_3", "mcl_farming:melontige_4", "mcl_farming:melontige_5", "mcl_farming:melontige_6", "mcl_farming:melontige_7"}, 30, 5)
|
||||
|
||||
-- Register actual melon, connected stems and stem-to-melon growth
|
||||
mcl_farming:add_gourd("mcl_farming:melontige_unconnect", "mcl_farming:melontige_linked", "mcl_farming:melontige_unconnect", stem_def, stem_drop, "mcl_farming:melon", melon_base_def, 25, 15)
|
||||
|
|
|
@ -114,7 +114,7 @@ minetest.register_craft({
|
|||
cooktime = 10,
|
||||
})
|
||||
|
||||
mcl_farming:add_plant("mcl_farming:potato", {"mcl_farming:potato_1", "mcl_farming:potato_2"}, 50, 20)
|
||||
mcl_farming:add_plant("plant_potato", "mcl_farming:potato", {"mcl_farming:potato_1", "mcl_farming:potato_2"}, 50, 20)
|
||||
|
||||
if minetest.get_modpath("doc") then
|
||||
doc.add_entry_alias("nodes", "mcl_farming:potato_1", "nodes", "mcl_farming:potato_2")
|
||||
|
|
|
@ -86,7 +86,7 @@ local pumpkin_base_def = {
|
|||
}
|
||||
|
||||
-- Register stem growth
|
||||
mcl_farming:add_plant("mcl_farming:pumpkintige_unconnect", {"mcl_farming:pumpkin_1", "mcl_farming:pumpkin_2", "mcl_farming:pumpkin_3", "mcl_farming:pumpkin_4", "mcl_farming:pumpkin_5", "mcl_farming:pumpkin_6", "mcl_farming:pumpkin_7"}, 30, 5)
|
||||
mcl_farming:add_plant("plant_pumpkin_stem", "mcl_farming:pumpkintige_unconnect", {"mcl_farming:pumpkin_1", "mcl_farming:pumpkin_2", "mcl_farming:pumpkin_3", "mcl_farming:pumpkin_4", "mcl_farming:pumpkin_5", "mcl_farming:pumpkin_6", "mcl_farming:pumpkin_7"}, 30, 5)
|
||||
|
||||
-- Register actual pumpkin, connected stems and stem-to-pumpkin growth
|
||||
mcl_farming:add_gourd("mcl_farming:pumpkintige_unconnect", "mcl_farming:pumpkintige_linked", "mcl_farming:pumpkintige_unconnect", stem_def, stem_drop, "mcl_farming:pumpkin_face", pumpkin_base_def, 30, 15)
|
||||
|
|
|
@ -1,41 +1,60 @@
|
|||
function mcl_farming:add_plant(full_grown, names, interval, chance)
|
||||
local plant_lists = {}
|
||||
|
||||
function mcl_farming:add_plant(identifier, full_grown, names, interval, chance)
|
||||
plant_lists[identifier] = {}
|
||||
plant_lists[identifier].full_grown = full_grown
|
||||
plant_lists[identifier].names = names
|
||||
minetest.register_abm({
|
||||
nodenames = names,
|
||||
interval = interval,
|
||||
chance = chance,
|
||||
action = function(pos, node)
|
||||
pos.y = pos.y-1
|
||||
if minetest.get_node(pos).name ~= "mcl_farming:soil_wet" and math.random(0, 9) > 0 then
|
||||
if minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z}).name ~= "mcl_farming:soil_wet" and math.random(0, 9) > 0 then
|
||||
return
|
||||
else
|
||||
mcl_farming:grow_plant(identifier, pos, node)
|
||||
end
|
||||
pos.y = pos.y+1
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.get_node_light(pos) < 10 then
|
||||
return
|
||||
end
|
||||
local step = nil
|
||||
for i,name in ipairs(names) do
|
||||
if name == node.name then
|
||||
step = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if step == nil then
|
||||
return
|
||||
end
|
||||
local new_node = {name=names[step+1]}
|
||||
if new_node.name == nil then
|
||||
new_node.name = full_grown
|
||||
end
|
||||
new_node.param = node.param
|
||||
new_node.param2 = node.param2
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Attempts to advance a plant at pos by one or more growth stages (if possible)
|
||||
-- identifier: Identifier of plant as defined by mcl_farming:add_plant
|
||||
-- pos: Position
|
||||
-- node: Node table
|
||||
-- stages: Number of stages to advance (optional, defaults to 1)
|
||||
function mcl_farming:grow_plant(identifier, pos, node, stages)
|
||||
if not minetest.get_node_light(pos) then
|
||||
return
|
||||
end
|
||||
if minetest.get_node_light(pos) < 10 then
|
||||
return
|
||||
end
|
||||
|
||||
local plant_info = plant_lists[identifier]
|
||||
local step = nil
|
||||
|
||||
for i, name in ipairs(plant_info.names) do
|
||||
if name == node.name then
|
||||
step = i
|
||||
break
|
||||
end
|
||||
end
|
||||
if step == nil then
|
||||
return
|
||||
end
|
||||
if not stages then
|
||||
stages = 1
|
||||
end
|
||||
local new_node = {name = plant_info.names[step+stages]}
|
||||
if new_node.name == nil then
|
||||
new_node.name = plant_info.full_grown
|
||||
end
|
||||
new_node.param = node.param
|
||||
new_node.param2 = node.param2
|
||||
minetest.set_node(pos, new_node)
|
||||
end
|
||||
|
||||
function mcl_farming:place_seed(itemstack, placer, pointed_thing, plantname)
|
||||
local pt = pointed_thing
|
||||
if not pt then
|
||||
|
|
|
@ -115,7 +115,7 @@ minetest.register_node("mcl_farming:wheat", {
|
|||
_mcl_blast_resistance = 0,
|
||||
})
|
||||
|
||||
mcl_farming:add_plant("mcl_farming:wheat", {"mcl_farming:wheat_1", "mcl_farming:wheat_2", "mcl_farming:wheat_3"}, 50, 20)
|
||||
mcl_farming:add_plant("plant_wheat", "mcl_farming:wheat", {"mcl_farming:wheat_1", "mcl_farming:wheat_2", "mcl_farming:wheat_3"}, 50, 20)
|
||||
|
||||
minetest.register_craftitem("mcl_farming:wheat_item", {
|
||||
description = "Wheat",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue