From faf3f60cffef0298662904044ae680df340e56cb Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Sat, 2 May 2020 21:04:03 +0200 Subject: [PATCH 1/9] Use uncarved pumpkin instead of carved in mapgen --- mods/MAPGEN/mcl_biomes/init.lua | 2 +- mods/MAPGEN/mcl_mapgen_core/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/MAPGEN/mcl_biomes/init.lua b/mods/MAPGEN/mcl_biomes/init.lua index a04822439..f198e09fa 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3538,7 +3538,7 @@ local function register_decorations() -- Pumpkin minetest.register_decoration({ deco_type = "simple", - decoration = "mcl_farming:pumpkin_face", + decoration = "mcl_farming:pumpkin", param2 = 0, param2_max = 3, place_on = {"group:grass_block_no_snow"}, diff --git a/mods/MAPGEN/mcl_mapgen_core/init.lua b/mods/MAPGEN/mcl_mapgen_core/init.lua index 259cee88b..69132927c 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -828,7 +828,7 @@ local function register_mgv6_decorations() -- Pumpkin minetest.register_decoration({ deco_type = "simple", - decoration = "mcl_farming:pumpkin_face", + decoration = "mcl_farming:pumpkin", param2 = 0, param2_max = 3, place_on = {"group:grass_block_no_snow"}, From 9b614c115c48fb717db36b59def309bde1ed0a08 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Tue, 28 Apr 2020 16:32:28 +0200 Subject: [PATCH 2/9] Grow uncarved pumpkin from seeds instead of carved Carved pumpkin has to be explicitly registered as a separate node, as registering a carved pumpkin node happened as a side effect of invoking mcl_farming:add_gourd() for the carved pumpkin. The iron / snow golem spawning checks that trigger whenever a carved pumpkin is placed had to be moved out of the mcl_farming:add_gourd() invocation to preserve the existing behaviour. Note that uncarved pumpkin must not be registered as a separate node, as invoking mcl_farming:add_gourd() for a registered node name leads to stems not updating when an adjacent node is manually placed or mined. --- mods/ITEMS/mcl_farming/pumpkin.lua | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index a38f11862..6c8f83537 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -108,7 +108,6 @@ local pumpkin_base_def = { _mcl_blast_resistance = 1, _mcl_hardness = 1, } -minetest.register_node("mcl_farming:pumpkin", pumpkin_base_def) local pumpkin_face_base_def = table.copy(pumpkin_base_def) pumpkin_face_base_def.description = S("Pumpkin") @@ -121,10 +120,17 @@ pumpkin_face_base_def.groups.armor_head=1 pumpkin_face_base_def.groups.non_combat_armor_head=1 pumpkin_face_base_def._mcl_armor_mob_range_factor = 0 pumpkin_face_base_def._mcl_armor_mob_range_mob = "mobs_mc:enderman" + pumpkin_face_base_def._mcl_armor_element = "head" pumpkin_face_base_def._mcl_armor_texture = "mcl_farming_pumpkin_face.png" pumpkin_face_base_def._mcl_armor_preview = "mcl_farming_pumpkin_face_preview.png" +pumpkin_face_base_def.on_construct = function(pos) + -- Attempt to spawn iron golem or snow golem + mobs_mc.tools.check_iron_golem_summon(pos) + mobs_mc.tools.check_snow_golem_summon(pos) +end + if minetest.get_modpath("mcl_armor") then local pumpkin_hud = {} local function add_pumpkin_hud(player) @@ -173,17 +179,13 @@ if minetest.get_modpath("mcl_armor") then pumpkin_hud[player] = nil end) end +minetest.register_node("mcl_farming:pumpkin_face", pumpkin_face_base_def) -- Register stem growth 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_face_base_def, 30, 15, "mcl_farming_pumpkin_stem_connected.png^[colorize:#FFA800:127", -function(pos) - -- Attempt to spawn iron golem or snow golem - mobs_mc.tools.check_iron_golem_summon(pos) - mobs_mc.tools.check_snow_golem_summon(pos) -end) +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") -- Jack o'Lantern minetest.register_node("mcl_farming:pumpkin_face_light", { From 9a53761b08bf6738f19320270791a38ba449188d Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 19:47:30 +0200 Subject: [PATCH 3/9] Remove pumpkin seeds recipe with carved pumpkin Shearing an uncarved pumpkin turns it into a carved pumpkin and drops four pumpkin seeds. As map generation and growing mechanics have been changed to generate uncarved pumpkins instead of carved, preserving a recipe to get seeds from carved pumpkins enables players to get twice the amount of seeds as intended. Because of this, the recipe must go. --- mods/ITEMS/mcl_farming/pumpkin.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 6c8f83537..14792448f 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -222,11 +222,6 @@ minetest.register_craft({ recipe = {{"mcl_farming:pumpkin"}} }) -minetest.register_craft({ - output = "mcl_farming:pumpkin_seeds 4", - recipe = {{"mcl_farming:pumpkin_face"}} -}) - minetest.register_craftitem("mcl_farming:pumpkin_pie", { description = S("Pumpkin Pie"), _doc_items_longdesc = S("A pumpkin pie is a tasty food item which can be eaten."), From 4fda54b0d1541a895c87b2da0470f6458b5e6524 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 19:58:21 +0200 Subject: [PATCH 4/9] Remove pumpkin pie recipe with carved pumpkin Shearing an uncarved pumpkin turns it into a carved pumpkin and drops four pumpkin seeds. As map generation and growing mechanics have been changed to generate uncarved pumpkins instead of carved, preserving a recipe to get pumpkin pie from carved pumpkins enabled players to get both seeds and pumpkin pie from grown pumpkins, which was unintended. --- mods/ITEMS/mcl_farming/pumpkin.lua | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 14792448f..fcfe3bd1a 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -239,11 +239,6 @@ minetest.register_craft({ output = "mcl_farming:pumpkin_pie", recipe = {"mcl_farming:pumpkin", "mcl_core:sugar", "mcl_throwing:egg"}, }) -minetest.register_craft({ - type = "shapeless", - output = "mcl_farming:pumpkin_pie", - recipe = {"mcl_farming:pumpkin_face", "mcl_core:sugar", "mcl_throwing:egg"}, -}) if minetest.get_modpath("doc") then From a2dd8c935d5195a17eedffa5b41efb48d809239f Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 20:12:26 +0200 Subject: [PATCH 5/9] Make villagers accept uncarved pumpkin in trades As map generation and growing mechanics have been changed to generate uncarved pumpkins instead of carved, requiring players to shear every pumpkin before trading it with villagers seems like useless busywork. --- mods/ENTITIES/mobs_mc/villager.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/villager.lua b/mods/ENTITIES/mobs_mc/villager.lua index 7fed4cbf8..a2b828e09 100644 --- a/mods/ENTITIES/mobs_mc/villager.lua +++ b/mods/ENTITIES/mobs_mc/villager.lua @@ -74,7 +74,7 @@ local professions = { }, { - { { "mcl_farming:pumpkin_face", 8, 13 }, E1 }, + { { "mcl_farming:pumpkin", 8, 13 }, E1 }, { E1, { "mcl_farming:pumpkin_pie", 2, 3} }, }, From e1d67a20959d1249277afcb05db40eb2f5c28495 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 17:15:40 +0100 Subject: [PATCH 6/9] Disconnect stems from carved pumpkins after dig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Carved pumpkins can end up being connected to a stem – either if they were grown in a previous version of MineClone2 or Mineclonia, or if a player carves them before harvesting them. This patch makes sure that stems turn into unconnected stems after such a carved pumpkin is dug. --- mods/ITEMS/mcl_farming/pumpkin.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index fcfe3bd1a..78883626c 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -179,7 +179,6 @@ if minetest.get_modpath("mcl_armor") then pumpkin_hud[player] = nil end) end -minetest.register_node("mcl_farming:pumpkin_face", pumpkin_face_base_def) -- Register stem growth 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) @@ -187,6 +186,10 @@ mcl_farming:add_plant("plant_pumpkin_stem", "mcl_farming:pumpkintige_unconnect", -- 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", 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 +minetest.register_node("mcl_farming:pumpkin_face", pumpkin_face_base_def) + -- Jack o'Lantern minetest.register_node("mcl_farming:pumpkin_face_light", { description = S("Jack o'Lantern"), From 56db8773601c09e7334567e54977398a63e09f41 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 18:14:44 +0100 Subject: [PATCH 7/9] 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. --- mods/ITEMS/mcl_farming/pumpkin.lua | 2 +- mods/ITEMS/mcl_farming/shared_functions.lua | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 78883626c..45ac2f611 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -187,7 +187,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 diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index e942415f5..7b9784503 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -185,7 +185,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 @@ -235,8 +235,8 @@ function mcl_farming:add_gourd(full_unconnected_stem, connected_stem_basename, s end -- Register gourd - if not gourd_def.after_dig_node then - function gourd_def.after_dig_node(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] From 5ba36c08b6007ec21d71b7bb539f153bf2aff160 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 18:54:03 +0100 Subject: [PATCH 8/9] Drop carved pumpkin when shearing snow golem --- mods/ENTITIES/mobs_mc/snowman.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ENTITIES/mobs_mc/snowman.lua b/mods/ENTITIES/mobs_mc/snowman.lua index 93f91c330..a5aaaac0f 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -124,6 +124,10 @@ mobs:register_mob("mobs_mc:snowman", { local pos = self.object:get_pos() minetest.sound_play("mcl_tools_shears_cut", {pos = pos}, true) + if minetest.registered_items["mcl_farming:pumpkin_face"] then + minetest.add_item({x=pos.x, y=pos.y+1.4, z=pos.z}, "mcl_farming:pumpkin_face") + end + -- Wear out if not minetest.is_creative_enabled(clicker:get_player_name()) then item:add_wear(mobs_mc.misc.shears_wear) From 67ae203772199b4b96bb5f189c7ee90e43178db3 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 14 Apr 2022 18:52:31 +0200 Subject: [PATCH 9/9] Trigger node callbacks when pumpkin is sheared The code for shearing a pumpkin used minetest.swap_node() to replace a faceless pumpkin with a carved pumpkin. This did not trigger the node callbacks of the carved pumpkin, which meant that shearing a pumpkin would not check for the snow golem or iron golem spawn conditions. This patch replaces minetest.swap_node() in the code for shearing a pumpkin with minetest.set_node(), which does trigger the callbacks; therefore snow and iron golems can now spawn as a pumpkin is carved. --- mods/ITEMS/mcl_tools/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_tools/init.lua b/mods/ITEMS/mcl_tools/init.lua index 1d68a0973..e1fdf7aba 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -238,7 +238,7 @@ if minetest.get_modpath("mcl_farming") then minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = pointed_thing.above}, true) local dir = vector.subtract(pointed_thing.under, pointed_thing.above) local param2 = minetest.dir_to_facedir(dir) - minetest.swap_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) + minetest.set_node(pointed_thing.under, {name="mcl_farming:pumpkin_face", param2 = param2}) minetest.add_item(pointed_thing.above, "mcl_farming:pumpkin_seeds 4") end return itemstack