meta:set_private("wet"), require only walkable nodes

This commit is contained in:
kno10 2024-11-02 21:05:57 +01:00 committed by the-real-herowl
parent a8318f6600
commit ebf6cf32e8
2 changed files with 7 additions and 4 deletions

View file

@ -307,12 +307,11 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s
or (dir == 3 and vector.offset(stempos, 0, 0, 1)) or (dir == 3 and vector.offset(stempos, 0, 0, 1))
or vector.offset(stempos, 0, 0, -1) or vector.offset(stempos, 0, 0, -1)
if minetest.get_node(neighbor).name ~= "air" then return end -- occupied if minetest.get_node(neighbor).name ~= "air" then return end -- occupied
-- check for suitable floor: grass, dirt, or soil -- check for suitable floor -- in contrast to MC, we think everything solid is fine
local floorpos = vector.offset(neighbor, 0, -1, 0) local floorpos = vector.offset(neighbor, 0, -1, 0)
local floorname = minetest.get_node(floorpos).name local floorname = minetest.get_node(floorpos).name
local floordef = minetest.registered_nodes[floorname] local floordef = minetest.registered_nodes[floorname]
if not floordef then return end if not floordef or not floordef.walkable then return end
if (floordef.groups.grass_block or 0) == 0 and (floordef.groups.dirt or 0) == 0 and (floordef.groups.soil or 0) < 2 then return end -- not suitable for growing
-- check moisture level -- check moisture level
local odds = floor(25 / (get_moisture_level(stempos) * get_same_crop_penalty(stempos))) + 1 local odds = floor(25 / (get_moisture_level(stempos) * get_same_crop_penalty(stempos))) + 1

View file

@ -72,6 +72,7 @@ minetest.register_abm({
node.name = "mcl_farming:soil_wet" node.name = "mcl_farming:soil_wet"
minetest.set_node(pos, node) -- resets wetness minetest.set_node(pos, node) -- resets wetness
meta:set_int("wet", 7) meta:set_int("wet", 7)
meta:mark_as_private("wet")
elseif wet < 7 then elseif wet < 7 then
meta:set_int("wet", 7) meta:set_int("wet", 7)
end end
@ -85,8 +86,11 @@ minetest.register_abm({
if node.name == "mcl_farming:soil_wet" then -- change visual appearance to dry if node.name == "mcl_farming:soil_wet" then -- change visual appearance to dry
node.name = "mcl_farming:soil" node.name = "mcl_farming:soil"
minetest.set_node(pos, node) minetest.set_node(pos, node)
meta:set_int("wet", wet - 1)
meta:mark_as_private("wet") -- after set_int
else
meta:set_int("wet", wet - 1)
end end
meta:set_int("wet", wet - 1)
return return
end end
-- Revert to dirt if wetness is 0, and no plant above -- Revert to dirt if wetness is 0, and no plant above