Disconnect gourd stems after destruct

While testing the previous commit, it became clear that gourd stems do
not disconnect properly if the gourd disappears while not being dug. A
simple method to create illegal curved stems was to explode the gourd.

This patch changes gourds so that the stem curves back after a gourd is
destroyed, regardless of reason. This hopefully makes curved stems that
are not connected to matching gourds a relict of the past.
master
Nils Dagsson Moskopp 2022-02-23 18:14:44 +01:00
parent 1967e10a52
commit c4912effaf
No known key found for this signature in database
GPG Key ID: A3BC671C35191080
2 changed files with 4 additions and 4 deletions

View File

@ -130,7 +130,7 @@ mcl_farming:add_plant("plant_pumpkin_stem", "mcl_farming:pumpkintige_unconnect",
mcl_farming:add_gourd("mcl_farming:pumpkintige_unconnect", "mcl_farming:pumpkintige_linked", "mcl_farming:pumpkintige_unconnect", stem_def, stem_drop, "mcl_farming:pumpkin", pumpkin_base_def, 30, 15, "mcl_farming_pumpkin_stem_connected.png^[colorize:#FFA800:127")
-- Steal function to properly disconnect a carved pumpkin
pumpkin_face_base_def.after_dig_node = minetest.registered_nodes["mcl_farming:pumpkin"].after_dig_node
pumpkin_face_base_def.after_destruct = minetest.registered_nodes["mcl_farming:pumpkin"].after_destruct
minetest.register_node("mcl_farming:pumpkin_face", pumpkin_face_base_def)
-- Jack o'Lantern

View File

@ -178,7 +178,7 @@ end
- stem_def: Partial node definition of the fully-grown unconnected stem node. Many fields are already defined. You need to add `tiles` and `description` at minimum. Don't define on_construct without good reason
- stem_drop: Drop probability table for all stem
- gourd_itemstring: Desired itemstring of the full gourd node
- gourd_def: (almost) full definition of the gourd node. This function will add on_construct and after_dig_node to the definition for unconnecting any connected stems
- gourd_def: (almost) full definition of the gourd node. This function will add on_construct and after_destruct to the definition for unconnecting any connected stems
- grow_interval: Will attempt to grow a gourd periodically at this interval in seconds
- grow_chance: Chance of 1/grow_chance to grow a gourd next to the full unconnected stem after grow_interval has passed. Must be a natural number
- connected_stem_texture: Texture of the connected stem
@ -228,8 +228,8 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s
end
-- Register gourd
if not gourd_def.after_dig_node then
gourd_def.after_dig_node = function(blockpos, oldnode, oldmetadata, user)
if not gourd_def.after_destruct then
gourd_def.after_destruct = function(blockpos, oldnode)
-- Disconnect any connected stems, turning them back to normal stems
for n=1, #neighbors do
local offset = neighbors[n]