From d59888c4df1a94392b3e05d0037f616c13d58322 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Sat, 2 May 2020 21:04:03 +0200 Subject: [PATCH 01/10] 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 66de6c13..6194b16e 100644 --- a/mods/MAPGEN/mcl_biomes/init.lua +++ b/mods/MAPGEN/mcl_biomes/init.lua @@ -3532,7 +3532,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 3dcf6bf9..97e68f95 100644 --- a/mods/MAPGEN/mcl_mapgen_core/init.lua +++ b/mods/MAPGEN/mcl_mapgen_core/init.lua @@ -868,7 +868,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 59b013f766dbaedbda47223682321479bacfa5e4 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Tue, 28 Apr 2020 16:32:28 +0200 Subject: [PATCH 02/10] 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/mods/ITEMS/mcl_farming/pumpkin.lua b/mods/ITEMS/mcl_farming/pumpkin.lua index 72b4e541..12044450 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -104,7 +104,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") @@ -115,20 +114,21 @@ pumpkin_face_base_def.groups.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.groups.non_combat_armor=1 +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 pumpkin_face_base_def.on_secondary_use = armor.on_armor_use 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 6381d65dbbfd7eea3545067f4e75b688995bf779 Mon Sep 17 00:00:00 2001 From: Alexander Minges Date: Wed, 6 May 2020 18:26:59 +0200 Subject: [PATCH 03/10] Use correct location for pumpkin shearing sound MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The code for turning an uncarved pumpkin into a carved pumpkin using the shears was using “above” instead of “pointed_thing.above” as the location for its sound. This resulted in a warning being logged when shears were being used on a pumpkin. This patch rectifies the issue. --- 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 99fcb213..8d8e6569 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -232,7 +232,7 @@ if minetest.get_modpath("mcl_farming") then local wear = mcl_autogroup.get_wear(toolname, "shearsy") itemstack:add_wear(wear) end - minetest.sound_play({name="default_grass_footstep", gain=1}, {pos = above}, true) + 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}) From a44fd9c88be84c121076ccc67483aa025705ecb8 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 19:47:30 +0200 Subject: [PATCH 04/10] 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 12044450..e147a7aa 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -165,11 +165,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 3948a0e7af773870353e2d958bbf1535c125befe Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 19:58:21 +0200 Subject: [PATCH 05/10] 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 e147a7aa..a19a2864 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -182,11 +182,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 f8d55ee61be766e9189d9977d0806855053bc5ae Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sat, 31 Jul 2021 20:12:26 +0200 Subject: [PATCH 06/10] 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 0021a1ad..e145284e 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 1967e10a52f36b0e5dcea7edaa4ad99866436ab3 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 17:15:40 +0100 Subject: [PATCH 07/10] 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 a19a2864..79e968f7 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -122,7 +122,6 @@ end if minetest.get_modpath("mcl_armor") then pumpkin_face_base_def.on_secondary_use = armor.on_armor_use 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) @@ -130,6 +129,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 c4912effaf79f7a9925ff2a96c907dcd75affa7e Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 18:14:44 +0100 Subject: [PATCH 08/10] 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 79e968f7..e7b1a72b 100644 --- a/mods/ITEMS/mcl_farming/pumpkin.lua +++ b/mods/ITEMS/mcl_farming/pumpkin.lua @@ -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 diff --git a/mods/ITEMS/mcl_farming/shared_functions.lua b/mods/ITEMS/mcl_farming/shared_functions.lua index 6be9e527..ce8f8725 100644 --- a/mods/ITEMS/mcl_farming/shared_functions.lua +++ b/mods/ITEMS/mcl_farming/shared_functions.lua @@ -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] From fdd3c5db866d5790022c0f19994b6855526e0045 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Wed, 23 Feb 2022 18:54:03 +0100 Subject: [PATCH 09/10] 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 1ee88b36..52c77c81 100644 --- a/mods/ENTITIES/mobs_mc/snowman.lua +++ b/mods/ENTITIES/mobs_mc/snowman.lua @@ -123,6 +123,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 7d2ef661751991831a655cab5d408006d1865600 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 14 Apr 2022 18:52:31 +0200 Subject: [PATCH 10/10] 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 8d8e6569..e0c59b18 100644 --- a/mods/ITEMS/mcl_tools/init.lua +++ b/mods/ITEMS/mcl_tools/init.lua @@ -235,7 +235,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