From 9a6c64d163dfa04eb3c2eba403c3db389994a237 Mon Sep 17 00:00:00 2001 From: debagos Date: Fri, 12 Jan 2024 18:08:54 +0100 Subject: [PATCH 1/8] Fix dead ongen saplings due to biome_lib secession (#35) * Replaced print with minetest.log in init.lua * Added moretrees_ongen group to ongen saplings * Added LBM and setting to enable it for non-functional ongen saplings due to biome_lib secession * Changed LBM run_at_every_load to true * Fixed luacheck warnings * Using random interval for node timer, like in the on_generated timer interval * Update init.lua * Update node_defs.lua --------- Co-authored-by: Niklp --- default_settings.txt | 4 ++++ init.lua | 15 ++++++++++++++- node_defs.lua | 10 +++++++++- settings.lua | 4 ++++ 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/default_settings.txt b/default_settings.txt index 9f8fc3c..55de6a7 100644 --- a/default_settings.txt +++ b/default_settings.txt @@ -130,6 +130,10 @@ moretrees.dates_item_drop_ichance = 10 -- inverse probability of ripe dates dr moretrees.sapling_interval = 100 moretrees.sapling_chance = 5 +-- Enable this only if you have used an old moretrees version which was using biome_lib +-- and when you notice large areas with ongen saplings that don't grow +moretrees.grow_legacy_saplings = false + -- If this variable is set to true, drop leaves out as entities during leaf -- decay, rather than just disappearing them. diff --git a/init.lua b/init.lua index 86bf1a6..851c0de 100644 --- a/init.lua +++ b/init.lua @@ -383,4 +383,17 @@ function moretrees.grow_fir_snow(pos) minetest.spawn_tree(pos,moretrees.fir_model) end -print("[Moretrees] Loaded (2013-02-11)") +if moretrees.grow_legacy_saplings then + minetest.register_lbm({ + name = "moretrees:grow_ongen_saplings", + label = "Grow legacy ongen saplings", + nodenames = {"group:moretrees_ongen"}, + run_at_every_load = true, + action = function(pos) + minetest.log("info", "[moretrees] Starting growth timer for legacy ongen sapling at "..minetest.pos_to_string(pos, 0)) + minetest.get_node_timer(pos):start(math.random(2, 10)) + end + }) +end + +minetest.log("info", "[moretrees] Loading done") diff --git a/node_defs.lua b/node_defs.lua index 8d452a8..4387148 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -471,7 +471,15 @@ for i in ipairs(moretrees.treelist) do }) end - local ongen_groups = {snappy=2,dig_immediate=3,flammable=2,attached_node=1,sapling=1,not_in_creative_inventory=1} + local ongen_groups = { + snappy = 2, + dig_immediate = 3, + flammable = 2, + attached_node = 1, + sapling = 1, + moretrees_ongen = 1, + not_in_creative_inventory = 1 + } if minetest.settings:get_bool("creative_mode", false) then ongen_groups["not_in_creative_inventory"]=nil end diff --git a/settings.lua b/settings.lua index 1eca07b..b7d83ef 100644 --- a/settings.lua +++ b/settings.lua @@ -74,6 +74,10 @@ moretrees.dates_item_drop_ichance = tonumber(stg:get("moretrees.dates_item_drop_ moretrees.sapling_interval = 100 moretrees.sapling_chance = 5 +-- Enable this only if you have used an old moretrees version which was using biome_lib +-- and when you notice large areas with ongen saplings that don't grow +moretrees.grow_legacy_saplings = stg:get_bool("moretrees.grow_legacy_saplings", false) + -- If this variable is set to true, drop leaves out as entities during leaf -- decay, rather than just disappearing them. moretrees.decay_leaves_as_items = stg:get_bool("moretrees.decay_leaves_as_items", false) From 670f7f4e6165b4c92e407a44b1e27c8ae55bfabe Mon Sep 17 00:00:00 2001 From: Luke aka SwissalpS Date: Sat, 9 Mar 2024 02:53:42 +0100 Subject: [PATCH 2/8] is_ground_content revision (#36) default minetest game treats fruit as ground content, let's mirror that. --- cocos_palm.lua | 1 + date_palm.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/cocos_palm.lua b/cocos_palm.lua index 83fbbe9..610b51a 100644 --- a/cocos_palm.lua +++ b/cocos_palm.lua @@ -177,6 +177,7 @@ for _,suffix in ipairs({"_0", "_1", "_2", "_3", ""}) do paramtype = "light", sunlight_propagates = true, walkable = false, + is_ground_content = false, groups = { fleshy=3, dig_immediate=3, flammable=2, moretrees_coconut=coco_group }, inventory_image = tile.."^[transformR180", wield_image = tile.."^[transformR180", diff --git a/date_palm.lua b/date_palm.lua index dfc8aaa..e514c58 100644 --- a/date_palm.lua +++ b/date_palm.lua @@ -723,6 +723,7 @@ for _,suffix in ipairs({"f0", "f1", "f2", "f3", "f4", "m0", "fn", "n"}) do paramtype = "light", sunlight_propagates = true, walkable = false, + is_ground_content = false, groups = { fleshy=3, dig_immediate=3, flammable=2, moretrees_dates=1 }, inventory_image = "moretrees_dates_"..suffix..".png^[transformR0", wield_image = "moretrees_dates_"..suffix..".png^[transformR90", From f49b1c42c9a526eeceecbc6af53353712d5f339e Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 26 May 2024 11:08:14 -0400 Subject: [PATCH 3/8] makes moretrees game agnostic (#37) * at least boot into minetest * start using some xcompat materials * transition some more materials * translate and default lock some more stuff * handle more stuff * translate leaves and bugfix jungle nodes near * fallback on moretrees spaling texture when default not present * fix https://github.com/mt-mods/moretrees/pull/37#discussion_r1615147786 --- .luacheckrc | 2 +- biome_defs.lua | 74 ++++++++++++++++++++++---------------------- cocos_palm.lua | 2 +- date_palm.lua | 2 +- init.lua | 50 +++++++++++++++--------------- mod.conf | 4 +-- node_defs.lua | 82 +++++++++++++++++++++++++++---------------------- saplings.lua | 12 ++++---- tree_models.lua | 6 ++-- 9 files changed, 122 insertions(+), 112 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 0e916a2..199e53f 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -21,8 +21,8 @@ read_globals = { string = {fields = {"split"}}, table = {fields = {"copy", "getn"}}, - "biome_lib", "stairsplus", "stairs", "doors", + "xcompat", } diff --git a/biome_defs.lua b/biome_defs.lua index 342c80d..7e4b505 100644 --- a/biome_defs.lua +++ b/biome_defs.lua @@ -1,6 +1,6 @@ moretrees.beech_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 8, seed_diff = 2, @@ -9,13 +9,13 @@ moretrees.beech_biome = { } moretrees.palm_biome = { - surface = "default:sand", + surface = xcompat.materials.sand, avoid_nodes = moretrees.avoidnodes, avoid_radius = 5, seed_diff = 330, min_elevation = -1, max_elevation = 1, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_count = 10, temp_min = 0.25, @@ -25,13 +25,13 @@ moretrees.palm_biome = { } moretrees.date_palm_biome = { - surface = "default:desert_sand", + surface = xcompat.materials.desert_sand, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 339, min_elevation = -1, max_elevation = 10, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 20, near_nodes_count = 100, near_nodes_vertical = 20, @@ -42,13 +42,13 @@ moretrees.date_palm_biome = { } moretrees.date_palm_biome_2 = { - surface = "default:desert_sand", + surface = xcompat.materials.desert_sand, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 340, min_elevation = 11, max_elevation = 30, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 1, near_nodes_count = 1, near_nodes_vertical = 30, @@ -59,7 +59,7 @@ moretrees.date_palm_biome_2 = { } moretrees.apple_tree_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 331, @@ -69,13 +69,13 @@ moretrees.apple_tree_biome = { temp_max = -0.15, rarity = 75, max_count = 5, - place_on = {"default:dirt_with_grass"}, + place_on = {xcompat.materials.dirt_with_grass}, biomes = {"deciduous_forest"}, fill_ratio = 0.0001, } moretrees.oak_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 15, seed_diff = 332, @@ -89,7 +89,7 @@ moretrees.oak_biome = { } moretrees.sequoia_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 333, @@ -103,7 +103,7 @@ moretrees.sequoia_biome = { } moretrees.birch_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 5, seed_diff = 334, @@ -117,13 +117,13 @@ moretrees.birch_biome = { } moretrees.willow_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 337, min_elevation = -5, max_elevation = 5, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_count = 5, rarity = 75, @@ -131,13 +131,13 @@ moretrees.willow_biome = { } moretrees.rubber_tree_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 338, min_elevation = -5, max_elevation = 5, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_count = 10, temp_min = -0.15, @@ -147,8 +147,8 @@ moretrees.rubber_tree_biome = { moretrees.jungletree_biome = { surface = { - "default:dirt", - "default:dirt_with_grass", + xcompat.materials.dirt, + xcompat.materials.dirt_with_grass, "woodsoils:dirt_with_leaves_1", "woodsoils:grass_with_leaves_1", "woodsoils:grass_with_leaves_2", @@ -160,16 +160,16 @@ moretrees.jungletree_biome = { rarity = 85, seed_diff = 329, min_elevation = 1, - near_nodes = {"default:jungletree"}, - near_nodes_size = 6, - near_nodes_vertical = 2, - near_nodes_count = 1, + near_nodes = minetest.get_modpath("default") and {"default:jungletree"} or nil, + near_nodes_size = minetest.get_modpath("default") and 6 or nil, + near_nodes_vertical = minetest.get_modpath("default") and 2 or nil, + near_nodes_count = minetest.get_modpath("default") and 1 or nil, plantlife_limit = -0.9, biomes = {"rainforest", "rainforest_swamp"}, } moretrees.spruce_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 335, @@ -181,12 +181,12 @@ moretrees.spruce_biome = { } moretrees.cedar_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 336, min_elevation = 0, --Added to solve an issue where cedar trees would sometimes spawn deep underground - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_count = 5, rarity = 50, @@ -196,13 +196,13 @@ moretrees.cedar_biome = { -- Poplar requires a lot of water. moretrees.poplar_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 6, seed_diff = 341, min_elevation = 0, max_elevation = 50, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_vertical = 5, near_nodes_count = 1, @@ -215,13 +215,13 @@ moretrees.poplar_biome = { -- The humidity requirement it quite restrictive (apparently). -- Spawn an occasional poplar elsewhere. moretrees.poplar_biome_2 = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 6, seed_diff = 341, min_elevation = 0, max_elevation = 50, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 15, near_nodes_vertical = 4, near_nodes_count = 10, @@ -233,13 +233,13 @@ moretrees.poplar_biome_2 = { -- Subterranean lakes provide enough water for poplars to grow moretrees.poplar_biome_3 = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 6, seed_diff = 342, min_elevation = 0, max_elevation = 50, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 1, near_nodes_vertical = 25, near_nodes_count = 1, @@ -250,13 +250,13 @@ moretrees.poplar_biome_3 = { } moretrees.poplar_small_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 4, seed_diff = 343, min_elevation = 0, max_elevation = 50, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 10, near_nodes_vertical = 5, near_nodes_count = 1, @@ -267,13 +267,13 @@ moretrees.poplar_small_biome = { } moretrees.poplar_small_biome_2 = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 4, seed_diff = 343, min_elevation = 0, max_elevation = 50, - near_nodes = {"default:water_source"}, + near_nodes = {xcompat.materials.water_source}, near_nodes_size = 10, near_nodes_vertical = 4, near_nodes_count = 5, @@ -285,7 +285,7 @@ moretrees.poplar_small_biome_2 = { moretrees.fir_biome = { - surface = "default:dirt_with_grass", + surface = xcompat.materials.dirt_with_grass, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 359, @@ -298,7 +298,7 @@ moretrees.fir_biome = { moretrees.fir_biome_snow = { surface = {"snow:dirt_with_snow", "snow:snow"}, - below_nodes = {"default:dirt", "default:dirt_with_grass", "snow:dirt_with_snow"}, + below_nodes = {xcompat.materials.dirt, xcompat.materials.dirt_with_grass, "snow:dirt_with_snow"}, avoid_nodes = moretrees.avoidnodes, avoid_radius = 10, seed_diff = 359, diff --git a/cocos_palm.lua b/cocos_palm.lua index 610b51a..bf9b753 100644 --- a/cocos_palm.lua +++ b/cocos_palm.lua @@ -181,7 +181,7 @@ for _,suffix in ipairs({"_0", "_1", "_2", "_3", ""}) do groups = { fleshy=3, dig_immediate=3, flammable=2, moretrees_coconut=coco_group }, inventory_image = tile.."^[transformR180", wield_image = tile.."^[transformR180", - sounds = default.node_sound_defaults(), + sounds = xcompat.sounds.node_sound_default(), drop = drop, selection_box = { type = "fixed", diff --git a/date_palm.lua b/date_palm.lua index e514c58..3b4261a 100644 --- a/date_palm.lua +++ b/date_palm.lua @@ -727,7 +727,7 @@ for _,suffix in ipairs({"f0", "f1", "f2", "f3", "f4", "m0", "fn", "n"}) do groups = { fleshy=3, dig_immediate=3, flammable=2, moretrees_dates=1 }, inventory_image = "moretrees_dates_"..suffix..".png^[transformR0", wield_image = "moretrees_dates_"..suffix..".png^[transformR90", - sounds = default.node_sound_defaults(), + sounds = xcompat.sounds.node_sound_default(), drop = dropfn, selection_box = { type = "fixed", diff --git a/init.lua b/init.lua index 851c0de..459b4da 100644 --- a/init.lua +++ b/init.lua @@ -15,29 +15,31 @@ moretrees = {} -minetest.override_item("default:sapling", { - description = "Sapling" -}) +if minetest.get_modpath("default") then + minetest.override_item("default:sapling", { + description = "Sapling" + }) -minetest.override_item("default:tree", { - description = "Tree" -}) + minetest.override_item("default:tree", { + description = "Tree" + }) -minetest.override_item("default:wood", { - description = "Wooden Planks" -}) + minetest.override_item("default:wood", { + description = "Wooden Planks" + }) -minetest.override_item("default:leaves", { - description = "Leaves" -}) + minetest.override_item("default:leaves", { + description = "Leaves" + }) -minetest.override_item("default:fence_wood", { - description = "Wooden Fence" -}) + minetest.override_item("default:fence_wood", { + description = "Wooden Fence" + }) -minetest.override_item("default:fence_rail_wood", { - description = "Wooden Fence Rail" -}) + minetest.override_item("default:fence_rail_wood", { + description = "Wooden Fence Rail" + }) +end if minetest.get_modpath("doors") then minetest.override_item("doors:gate_wood_closed", { @@ -89,10 +91,10 @@ end -- tables, load other files moretrees.cutting_tools = { - "default:axe_bronze", - "default:axe_diamond", "default:axe_mese", - "default:axe_steel", + xcompat.materials.axe_steel, + xcompat.materials.axe_diamond, + xcompat.materials.axe_bronze, "glooptest:axe_alatro", "glooptest:axe_arol", "moreores:axe_mithril", @@ -313,7 +315,7 @@ function moretrees.grow_jungletree(pos) minetest.swap_node(pos, {name = "air"}) local leaves = minetest.find_nodes_in_area( {x = pos.x-1, y = pos.y, z = pos.z-1}, {x = pos.x+1, y = pos.y+10, z = pos.z+1}, - "default:leaves" + xcompat.materials.apple_leaves ) for leaf in ipairs(leaves) do minetest.swap_node(leaves[leaf], {name = "air"}) @@ -344,7 +346,7 @@ function moretrees.grow_fir(pos) local leaves = minetest.find_nodes_in_area( {x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, - "default:leaves" + xcompat.materials.apple_leaves ) for leaf in ipairs(leaves) do minetest.swap_node(leaves[leaf], {name = "air"}) @@ -375,7 +377,7 @@ function moretrees.grow_fir_snow(pos) local leaves = minetest.find_nodes_in_area( {x = pos.x, y = pos.y, z = pos.z}, {x = pos.x, y = pos.y+5, z = pos.z}, - "default:leaves" + xcompat.materials.apple_leaves ) for leaf in ipairs(leaves) do minetest.swap_node(leaves[leaf], {name = "air"}) diff --git a/mod.conf b/mod.conf index a8bfea1..bbbcc4c 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = moretrees -depends = default, vessels -optional_depends = doors, stairs, moreblocks, farming +depends = xcompat +optional_depends = doors, stairs, moreblocks, farming, default, vessels min_minetest_version = 5.2.0 diff --git a/node_defs.lua b/node_defs.lua index 4387148..d805eac 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -2,6 +2,9 @@ local S = minetest.get_translator("moretrees") moretrees.avoidnodes = {} +local jungle_sapling_texture = minetest.get_modpath("default") and "default_junglesapling.png" + or "moretrees_cedar_sapling.png" + moretrees.treelist = { {"beech", S("Beech Tree")}, {"apple_tree", S("Apple Tree")}, @@ -17,7 +20,7 @@ moretrees.treelist = { {"willow", S("Willow Tree")}, {"rubber_tree", S("Rubber Tree")}, {"fir", S("Douglas Fir"), "fir_cone", S("Fir Cone"), {-0.2, -0.5, -0.2, 0.2, 0, 0.2}, 0.8 }, - {"jungletree", S("Jungle Tree"), nil, nil, nil, nil, "default_junglesapling.png" }, + {"jungletree", S("Jungle Tree"), nil, nil, nil, nil, jungle_sapling_texture }, } moretrees.treedesc = { @@ -223,8 +226,8 @@ end -- redefine default leaves to handle plantlike and/or leaf decay options -if moretrees.plantlike_leaves then - minetest.override_item("default:leaves", { +if minetest.get_modpath("default") and moretrees.plantlike_leaves then + minetest.override_item(xcompat.materials.apple_leaves, { inventory_image = minetest.inventorycube("default_leaves.png"), drawtype = "plantlike", visual_scale = math.sqrt(2) @@ -233,8 +236,8 @@ end -- redefine default jungle leaves for same -if moretrees.plantlike_leaves then - minetest.override_item("default:jungleleaves", { +if minetest.get_modpath("default") and moretrees.plantlike_leaves then + minetest.override_item(xcompat.materials.jungle_leaves, { inventory_image = minetest.inventorycube("default_jungleleaves.png"), drawtype = "plantlike", visual_scale = math.sqrt(2) @@ -280,7 +283,7 @@ for i in ipairs(moretrees.treelist) do paramtype2 = "facedir", is_ground_content = false, groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, - sounds = default.node_sound_wood_defaults(), + sounds = xcompat.sounds.node_sound_wood_defaults(), on_place = minetest.rotate_node, }) @@ -289,7 +292,7 @@ for i in ipairs(moretrees.treelist) do tiles = {"moretrees_"..treename.."_wood.png"}, is_ground_content = false, groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, - sounds = default.node_sound_wood_defaults(), + sounds = xcompat.sounds.node_sound_wood_defaults(), }) local moretrees_leaves_inventory_image = nil @@ -311,7 +314,7 @@ for i in ipairs(moretrees.treelist) do paramtype = "light", is_ground_content = false, groups = {snappy = 3, flammable = 2, leaves = 1, moretrees_leaves = 1, leafdecay = 1}, - sounds = default.node_sound_leaves_defaults(), + sounds = xcompat.sounds.node_sound_leaves_defaults(), drop = { max_items = 1, @@ -365,7 +368,7 @@ for i in ipairs(moretrees.treelist) do }, moretrees.treedesc[treename].trunk_stair, moretrees.treedesc[treename].trunk_slab, - default.node_sound_wood_defaults() + xcompat.sounds.node_sound_wood_defaults() ) stairs.register_stair_and_slab( @@ -375,13 +378,13 @@ for i in ipairs(moretrees.treelist) do { "moretrees_"..treename.."_wood.png" }, moretrees.treedesc[treename].planks_stair, moretrees.treedesc[treename].planks_slab, - default.node_sound_wood_defaults() + xcompat.sounds.node_sound_wood_defaults() ) end end - if moretrees.enable_fences then + if minetest.get_modpath("default") and moretrees.enable_fences then local planks_name = "moretrees:" .. treename .. "_planks" local planks_tile = "moretrees_" .. treename .. "_wood.png" default.register_fence("moretrees:" .. treename .. "_fence", { @@ -393,7 +396,7 @@ for i in ipairs(moretrees.treelist) do "^default_fence_overlay.png^[makealpha:255,126,126", material = planks_name, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, - sounds = default.node_sound_wood_defaults() + sounds = xcompat.sounds.node_sound_wood_defaults() }) default.register_fence_rail("moretrees:" .. treename .. "_fence_rail", { description = moretrees.treedesc[treename].fence_rail, @@ -404,7 +407,7 @@ for i in ipairs(moretrees.treelist) do "^default_fence_rail_overlay.png^[makealpha:255,126,126", material = planks_name, groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2}, - sounds = default.node_sound_wood_defaults() + sounds = xcompat.sounds.node_sound_wood_defaults() }) if minetest.global_exists("doors") then doors.register_fencegate("moretrees:" .. treename .. "_gate", { @@ -438,7 +441,7 @@ for i in ipairs(moretrees.treelist) do fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, groups = regular_groups, - sounds = default.node_sound_defaults(), + sounds = xcompat.sounds.node_sound_default(), on_place = function(itemstack, placer, pointed_thing) itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, "moretrees:" ..treename.. "_sapling", @@ -497,7 +500,7 @@ for i in ipairs(moretrees.treelist) do fixed = {-0.3, -0.5, -0.3, 0.3, 0.35, 0.3} }, groups = ongen_groups, - sounds = default.node_sound_defaults(), + sounds = xcompat.sounds.node_sound_default(), drop = "moretrees:"..treename.."_sapling", on_place = function(itemstack, placer, pointed_thing) itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, @@ -549,7 +552,7 @@ for i in ipairs(moretrees.treelist) do fixed = selbox }, groups = {fleshy=3,dig_immediate=3,flammable=2, attached_node=1, leafdecay = 1, leafdecay_drop = 1}, - sounds = default.node_sound_defaults(), + sounds = xcompat.sounds.node_sound_default(), after_place_node = function(pos, placer) if placer:is_player() then minetest.set_node(pos, {name = "moretrees:"..fruit, param2 = 1}) @@ -560,7 +563,8 @@ for i in ipairs(moretrees.treelist) do if treename ~= "jungletree" and treename ~= "poplar_small" - and treename ~= "pine" then + and treename ~= "pine" + and minetest.get_modpath("default") then default.register_leafdecay({ trunks = { "moretrees:"..treename.."_trunk" }, leaves = { "moretrees:"..treename.."_leaves", fruitname }, @@ -625,29 +629,31 @@ for color = 1, #jungleleaves do paramtype = "light", is_ground_content = false, groups = {snappy = 3, flammable = 2, leaves = 1, moretrees_leaves = 1, leafdecay = 3 }, - drop = { + drop = minetest.get_modpath("default") and { max_items = 1, items = { {items = {"default:junglesapling"}, rarity = 100 }, {items = {"moretrees:jungletree_leaves_"..jungleleaves[color]} } } - }, - sounds = default.node_sound_leaves_defaults(), + } or nil, + sounds = xcompat.sounds.node_sound_leaves_defaults(), }) end -- To get Moretrees to generate its own jungle trees among the default mapgen -- we need our own copy of that node, which moretrees will match against. -local jungle_tree = table.copy(minetest.registered_nodes["default:jungletree"]) -jungle_tree.drop = "default:jungletree" -minetest.register_node("moretrees:jungletree_trunk", jungle_tree) +if minetest.get_modpath("default") then + local jungle_tree = table.copy(minetest.registered_nodes["default:jungletree"]) + jungle_tree.drop = "default:jungletree" + minetest.register_node("moretrees:jungletree_trunk", jungle_tree) -default.register_leafdecay({ - trunks = { "default:jungletree", "moretrees:jungletree_trunk" }, - leaves = { "default:jungleleaves", "moretrees:jungletree_leaves_yellow", "moretrees:jungletree_leaves_red" }, - radius = moretrees.leafdecay_radius, -}) + default.register_leafdecay({ + trunks = { "default:jungletree", "moretrees:jungletree_trunk" }, + leaves = { xcompat.materials.jungle_leaves, "moretrees:jungletree_leaves_yellow", "moretrees:jungletree_leaves_red" }, + radius = moretrees.leafdecay_radius, + }) +end -- Extra needles for firs @@ -674,17 +680,19 @@ minetest.register_node("moretrees:fir_leaves_bright", { {items = {'moretrees:fir_leaves_bright'} } } }, - sounds = default.node_sound_leaves_defaults() + sounds = xcompat.sounds.node_sound_leaves_defaults() }) -default.register_leafdecay({ - trunks = { "moretrees:fir_trunk" }, - leaves = { "moretrees:fir_leaves", "moretrees:fir_leaves_bright" }, - radius = moretrees.leafdecay_radius, -}) +if minetest.get_modpath("default") then + default.register_leafdecay({ + trunks = { "moretrees:fir_trunk" }, + leaves = { "moretrees:fir_leaves", "moretrees:fir_leaves_bright" }, + radius = moretrees.leafdecay_radius, + }) +end -if moretrees.enable_redefine_apple then +if minetest.get_modpath("default") and moretrees.enable_redefine_apple then local appledef = table.copy(minetest.registered_nodes["default:apple"]) appledef.groups.attached_node = 1 minetest.register_node(":default:apple", appledef) @@ -712,7 +720,7 @@ minetest.register_node("moretrees:rubber_tree_trunk_empty", { "moretrees_rubber_tree_trunk_empty.png" }, groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2}, - sounds = default.node_sound_wood_defaults(), + sounds = xcompat.sounds.node_sound_wood_defaults(), paramtype2 = "facedir", is_ground_content = false, on_place = minetest.rotate_node, @@ -758,7 +766,7 @@ minetest.register_alias("conifers:sapling", "moretrees:fir_sapling") minetest.register_alias("moretrees:jungletree_sapling", "default:junglesapling") minetest.register_alias("moretrees:jungletree_trunk_sideways", "moreblocks:horizontal_jungle_tree") minetest.register_alias("moretrees:jungletree_planks", "default:junglewood") -minetest.register_alias("moretrees:jungletree_leaves_green", "default:jungleleaves") +minetest.register_alias("moretrees:jungletree_leaves_green", xcompat.materials.jungle_leaves) minetest.register_alias("moretrees:acacia_trunk", "default:acacia_tree") minetest.register_alias("moretrees:acacia_planks", "default:acacia_wood") diff --git a/saplings.lua b/saplings.lua index 09b1744..32ef7a8 100644 --- a/saplings.lua +++ b/saplings.lua @@ -5,8 +5,8 @@ local dirt_surfaces = { set = true, - ["default:dirt"] = true, - ["default:dirt_with_grass"] = true, + [xcompat.materials.dirt] = true, + [xcompat.materials.dirt_with_grass] = true, ["default:dirt_with_dry_grass"] = true, ["default:dirt_with_coniferous_litter"] = true, ["default:dirt_with_rainforest_litter"] = true, @@ -18,8 +18,8 @@ local dirt_surfaces = { local conifer_surfaces = { set = true, - ["default:dirt"] = true, - ["default:dirt_with_grass"] = true, + [xcompat.materials.dirt] = true, + [xcompat.materials.dirt_with_grass] = true, ["default:dirt_with_dry_grass"] = true, ["default:dirt_with_coniferous_litter"] = true, ["default:dirt_with_rainforest_litter"] = true, @@ -32,8 +32,8 @@ local conifer_surfaces = { local sand_surfaces = { set = true, - ["default:sand"] = true, - ["default:desert_sand"] = true, + [xcompat.materials.sand] = true, + [xcompat.materials.desert_sand] = true, ["cottages:loam"] = true, -- note, no silver sand here. -- too cold for a palm, too... well... sandy for anything else. diff --git a/tree_models.lua b/tree_models.lua index 8be3ec1..7824ea6 100644 --- a/tree_models.lua +++ b/tree_models.lua @@ -25,8 +25,8 @@ moretrees.apple_tree_model={ random_level=0, trunk_type="single", thin_branches=true, - fruit="default:apple", - fruit_chance=15, + fruit=minetest.get_modpath("default") and "default:apple" or nil, + fruit_chance=minetest.get_modpath("default") and 15 or nil, } moretrees.oak_model={ @@ -252,7 +252,7 @@ moretrees.jungletree_model={ rules_a=nil, rules_b=nil, trunk="moretrees:jungletree_trunk", - leaves="default:jungleleaves", + leaves=xcompat.materials.jungle_leaves, leaves2=nil, leaves2_chance=nil, angle=45, From 1b6914bc26c0afdedc97ebe13e5d989bd370f172 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Mon, 27 May 2024 10:25:10 -0400 Subject: [PATCH 4/8] tune for voxel garden (#40) * tune for voxel garden based off https://github.com/mt-mods/moretrees/pull/38 * add internal api setting rather than same if statement all over the place, per j-r suggestion --- crafts.lua | 16 +++++++------ node_defs.lua | 62 ++++++++++++++++++++++++++++----------------------- settings.lua | 3 +++ 3 files changed, 46 insertions(+), 35 deletions(-) diff --git a/crafts.lua b/crafts.lua index 360f984..918f37b 100644 --- a/crafts.lua +++ b/crafts.lua @@ -3,13 +3,15 @@ local S = minetest.get_translator("moretrees") for i in ipairs(moretrees.treelist) do local treename = moretrees.treelist[i][1] - minetest.register_craft({ - type = "shapeless", - output = "moretrees:"..treename.."_planks 4", - recipe = { - "moretrees:"..treename.."_trunk" - } - }) + if moretrees.enable_planks then + minetest.register_craft({ + type = "shapeless", + output = "moretrees:"..treename.."_planks 4", + recipe = { + "moretrees:"..treename.."_trunk" + } + }) + end minetest.register_craft({ type = "fuel", diff --git a/node_defs.lua b/node_defs.lua index d805eac..9c406ed 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -287,13 +287,15 @@ for i in ipairs(moretrees.treelist) do on_place = minetest.rotate_node, }) - minetest.register_node("moretrees:"..treename.."_planks", { - description = moretrees.treedesc[treename].planks, - tiles = {"moretrees_"..treename.."_wood.png"}, - is_ground_content = false, - groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, - sounds = xcompat.sounds.node_sound_wood_defaults(), - }) + if moretrees.enable_planks then + minetest.register_node("moretrees:"..treename.."_planks", { + description = moretrees.treedesc[treename].planks, + tiles = {"moretrees_"..treename.."_wood.png"}, + is_ground_content = false, + groups = {snappy=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1}, + sounds = xcompat.sounds.node_sound_wood_defaults(), + }) + end local moretrees_leaves_inventory_image = nil local moretrees_new_leaves_waving = nil @@ -346,17 +348,19 @@ for i in ipairs(moretrees.treelist) do } ) - stairsplus:register_all( - "moretrees", - treename.."_planks", - "moretrees:"..treename.."_planks", - { - groups = { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, not_in_creative_inventory=1 }, - tiles = { "moretrees_"..treename.."_wood.png" }, - description = moretrees.treedesc[treename].planks, - drop = treename.."_planks", - } - ) + if moretrees.enable_planks then + stairsplus:register_all( + "moretrees", + treename.."_planks", + "moretrees:"..treename.."_planks", + { + groups = { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, not_in_creative_inventory=1 }, + tiles = { "moretrees_"..treename.."_wood.png" }, + description = moretrees.treedesc[treename].planks, + drop = treename.."_planks", + } + ) + end elseif minetest.get_modpath("stairs") then stairs.register_stair_and_slab( "moretrees_"..treename.."_trunk", @@ -371,20 +375,22 @@ for i in ipairs(moretrees.treelist) do xcompat.sounds.node_sound_wood_defaults() ) - stairs.register_stair_and_slab( - "moretrees_"..treename.."_planks", - "moretrees:"..treename.."_planks", - { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3 }, - { "moretrees_"..treename.."_wood.png" }, - moretrees.treedesc[treename].planks_stair, - moretrees.treedesc[treename].planks_slab, - xcompat.sounds.node_sound_wood_defaults() - ) + if moretrees.enable_planks then + stairs.register_stair_and_slab( + "moretrees_"..treename.."_planks", + "moretrees:"..treename.."_planks", + { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3 }, + { "moretrees_"..treename.."_wood.png" }, + moretrees.treedesc[treename].planks_stair, + moretrees.treedesc[treename].planks_slab, + xcompat.sounds.node_sound_wood_defaults() + ) + end end end - if minetest.get_modpath("default") and moretrees.enable_fences then + if minetest.get_modpath("default") and moretrees.enable_fences and moretrees.enable_planks then local planks_name = "moretrees:" .. treename .. "_planks" local planks_tile = "moretrees_" .. treename .. "_wood.png" default.register_fence("moretrees:" .. treename .. "_fence", { diff --git a/settings.lua b/settings.lua index b7d83ef..78e4f7c 100644 --- a/settings.lua +++ b/settings.lua @@ -81,3 +81,6 @@ moretrees.grow_legacy_saplings = stg:get_bool("moretrees.grow_legacy_saplings", -- If this variable is set to true, drop leaves out as entities during leaf -- decay, rather than just disappearing them. moretrees.decay_leaves_as_items = stg:get_bool("moretrees.decay_leaves_as_items", false) + +-- this is an internal setting for games that only have one type of planks +moretrees.enable_planks = xcompat.gameid ~= "voxelgarden" \ No newline at end of file From 3e424b2797723640a4c915da664f30fbd9e80934 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Mon, 27 May 2024 12:18:58 -0400 Subject: [PATCH 5/8] culls settings (#41) * load all trees * remove now sorta duplicate settings * remove dead settings * prune useless file * prune dead settings --- default_settings.txt | 140 ------------------------------------------- init.lua | 83 +++++++------------------ node_defs.lua | 106 ++++++++++++++++---------------- settings.lua | 33 ---------- 4 files changed, 72 insertions(+), 290 deletions(-) delete mode 100644 default_settings.txt diff --git a/default_settings.txt b/default_settings.txt deleted file mode 100644 index 55de6a7..0000000 --- a/default_settings.txt +++ /dev/null @@ -1,140 +0,0 @@ --- Global configuration variables - --- Enable the various kinds of trees. - -moretrees.enable_apple_tree = true -moretrees.enable_oak = true -moretrees.enable_sequoia = true -moretrees.enable_palm = true -moretrees.enable_date_palm = true -moretrees.enable_cedar = true -moretrees.enable_rubber_tree = true -moretrees.enable_willow = true -moretrees.enable_birch = true -moretrees.enable_spruce = true -moretrees.enable_jungle_tree = true -moretrees.enable_fir = true -moretrees.enable_poplar = true -moretrees.enable_beech = false - --- set this to true to make moretrees spawn saplings at mapgen time instead --- of fully-grown trees, which will grow into full trees after a very short --- delay. This reduces mapgen lag in some situations, and fixes situations --- where the mapgen conflicts with the tree generator. - -moretrees.spawn_saplings = true - --- Set this to true to allow defining stairs/slabs/etc. If Moreblocks is --- installed, this will use that mod's Stairs Plus component. Otherwise, it --- will use the default stairs mod in minetest_game, if present - -moretrees.enable_stairs = true - --- If this variable is set to true, register fences for moretrees wood - -moretrees.enable_fences = false - --- Set this to true if you want the plantlike drawtype for leaves, which --- improves some peoples' framerates without resorting to making leaf nodes opaque. --- Affects default leaves and default jungle leaves also. - -moretrees.plantlike_leaves = false - --- Enable this if you want moretrees to redefine default apples so that they --- fall when leaves decay/are dug. - -moretrees.enable_redefine_apple = true - --- Set this to true to enable leaf decay of all trees except the default ones. - -moretrees.enable_leafdecay = true - --- various related settings to configure leaf decay. - -moretrees.leafdecay_delay = 2 -moretrees.leafdecay_chance = 5 -moretrees.leafdecay_radius = 5 -moretrees.palm_leafdecay_radius = 10 -moretrees.date_palm_leafdecay_radius = 14 - --- Change these settings if you want default trees to be gradually cut down --- above the elevation where firs normally generate. - -moretrees.firs_remove_default_trees = false -moretrees.firs_remove_interval = 2 -moretrees.firs_remove_chance = 150 - --- Cocos palm settings - -moretrees.coconuts_regrow = true -moretrees.coconuts_convert_existing_palms = true -- Converting existing palm trees will make coconuts regrow on them as well - -- Else, they will only regrow on newly-spawned palms - -- However, conversion is not an exact science, and although an attempt is - -- made to detect whether a trunk belongs to an actual palm, some coconut trunks - -- and some coconuts may be incorrectly converted. -moretrees.coconut_flower_interval = 59 -moretrees.coconut_flower_chance = 67 -moretrees.coconut_grow_interval = 2 * moretrees.coconut_flower_interval * moretrees.coconut_flower_chance - -- Actual interval will randomly vary between 67% and 133% of this value - -- 2 * 59 * 67 ~ 2 hours. So flowers become coconuts in about 6 hours -moretrees.coconut_item_drop_ichance = 10 -- inverse probability of ripe coconuts dropping as items (instead of disappearing) - --- Date palm settings - --- Suggested configuration alternatives: --- - Dates grow only when pollinated: --- - Set dates_regrow_pollinated to true --- - Set dates_regrow_unpollinated_percent to 0 --- - Dates grow without pollination. Pollination disabled: --- - Set dates_regrow_pollinated to false --- - Set dates_regrow_unpollinated_percent to some larger positive value, e.g. 95 --- - Dates grow, but more and faster if male flowers are nearby --- - Set dates_regrow_pollinated to true --- - Set dates_regrow_unpollinated_percent to some small positive value, e.g. 33 --- - Optional but recommended: Reduce the pollination distance, e.g. to 30 - --- Note that it should not be necessary to disable pollination for performance --- reasons. A lot of effort has gone into ensuring that date growing will not cause lag. --- --- If lag is suspected, use the chat command '/dates_stats' to obtain the male dates --- search time, as well as the counts of total number of searches requested and the --- number of searches actually performed. - -moretrees.dates_regrow_pollinated = true -- Enable pollination. If enabled, male trees are required for dates to grow. - -- If disabled, dates_regrow_unpollinated_percent must be non-zero for dates to regrow. -moretrees.dates_regrow_unpollinated_percent = 0 -- Percentage of female dates becoming dates without being pollinated. - -- If 0, dates_regrow_pollinated must be enabled for dates to grow. -moretrees.dates_female_percent = 57 -- Ratio of female to male trees - tune this to improve # of generated trees that actually bear fruit - -- ~57% gives near optimal results for groups of 3 random trees, while it is only slightly suboptimal - -- for groups of 2 and 4 random trees (~2% less fruit than optimal). - -- Optimal values per group size: 2: 50%, 3: 57.78%, 4: 63%, 5: 66.9%, 6: 69.9%, [...], 12: 79.8% - -- So 57% is optimal for small groups of trees. As larger groups have more female palms anyway, a - -- less than optimal proportion of female to male trees is not a problem. -moretrees.dates_pollination_distance = 120 -moretrees.dates_blossom_search_time_treshold = 1000 -- If average male blossom search time (in microseconds) exceeds this, start limiting the search load. -moretrees.dates_blossom_search_iload = 10 -- Inverse fraction of CPU time that male blossom searching search may consume. - -- As searching a large area (radius: dates_pollination_distance/3 per attempt) can cause lag, - -- this limits the search frequency server-wide so that the impact on server lag is minimised - -- For personal servers, this can be set lower, or even to 1 or 0 (0 disables load limiting). - -- Obtain the current average search time using /dates_stats -moretrees.dates_flower_interval = 59 -moretrees.dates_flower_chance = 181 -moretrees.dates_grow_interval = 2 * moretrees.dates_flower_interval * moretrees.dates_flower_chance - -- As date palms have a high yield, don't grow dates too fast - -- The actual interval will vary randomly between 67% and 133% of this value. - -- 2 * 59 * 181 ~ 6 hours. So by default flowers become dates in about one (human) day. -moretrees.dates_item_drop_ichance = 10 -- inverse probability of ripe dates dropping as items (instead of disappearing) - --- Sapling settings - -moretrees.sapling_interval = 100 -moretrees.sapling_chance = 5 - --- Enable this only if you have used an old moretrees version which was using biome_lib --- and when you notice large areas with ongen saplings that don't grow -moretrees.grow_legacy_saplings = false - --- If this variable is set to true, drop leaves out as entities during leaf --- decay, rather than just disappearing them. - -moretrees.decay_leaves_as_items = false diff --git a/init.lua b/init.lua index 459b4da..11e3760 100644 --- a/init.lua +++ b/init.lua @@ -151,69 +151,28 @@ function translate_biome_defs(def, treename, index) return deco_def end -if moretrees.enable_beech then - minetest.register_decoration(translate_biome_defs(moretrees.beech_biome, "beech")) -end - -if moretrees.enable_apple_tree then - minetest.register_decoration(translate_biome_defs(moretrees.apple_tree_biome, "apple_tree")) -end - -if moretrees.enable_oak then - minetest.register_decoration(translate_biome_defs(moretrees.oak_biome, "oak")) -end - -if moretrees.enable_sequoia then - minetest.register_decoration(translate_biome_defs(moretrees.sequoia_biome, "sequoia")) -end - -if moretrees.enable_palm then - minetest.register_decoration(translate_biome_defs(moretrees.palm_biome, "palm")) -end - -if moretrees.enable_date_palm then - minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome, "date_palm", 1)) - minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome_2, "date_palm", 2)) -end - -if moretrees.enable_cedar then - minetest.register_decoration(translate_biome_defs(moretrees.cedar_biome, "cedar")) -end - -if moretrees.enable_rubber_tree then - minetest.register_decoration(translate_biome_defs(moretrees.rubber_tree_biome, "rubber_tree")) -end - -if moretrees.enable_willow then - minetest.register_decoration(translate_biome_defs(moretrees.willow_biome, "willow")) -end - -if moretrees.enable_birch then - minetest.register_decoration(translate_biome_defs(moretrees.birch_biome, "birch")) -end - -if moretrees.enable_spruce then - minetest.register_decoration(translate_biome_defs(moretrees.spruce_biome, "spruce")) -end - -if moretrees.enable_jungle_tree then - minetest.register_decoration(translate_biome_defs(moretrees.jungletree_biome, "jungletree")) -end - -if moretrees.enable_fir then - minetest.register_decoration(translate_biome_defs(moretrees.fir_biome, "fir", 1)) - if minetest.get_modpath("snow") then - minetest.register_decoration(translate_biome_defs(moretrees.fir_biome_snow, "fir", 2)) - end -end - -if moretrees.enable_poplar then - minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome, "poplar", 1)) - minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_2, "poplar", 2)) - minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_3, "poplar", 3)) - minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome, "poplar_small", 4)) - minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome_2, "poplar_small", 5)) +minetest.register_decoration(translate_biome_defs(moretrees.beech_biome, "beech")) +minetest.register_decoration(translate_biome_defs(moretrees.apple_tree_biome, "apple_tree")) +minetest.register_decoration(translate_biome_defs(moretrees.oak_biome, "oak")) +minetest.register_decoration(translate_biome_defs(moretrees.sequoia_biome, "sequoia")) +minetest.register_decoration(translate_biome_defs(moretrees.palm_biome, "palm")) +minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome, "date_palm", 1)) +minetest.register_decoration(translate_biome_defs(moretrees.date_palm_biome_2, "date_palm", 2)) +minetest.register_decoration(translate_biome_defs(moretrees.cedar_biome, "cedar")) +minetest.register_decoration(translate_biome_defs(moretrees.rubber_tree_biome, "rubber_tree")) +minetest.register_decoration(translate_biome_defs(moretrees.willow_biome, "willow")) +minetest.register_decoration(translate_biome_defs(moretrees.birch_biome, "birch")) +minetest.register_decoration(translate_biome_defs(moretrees.spruce_biome, "spruce")) +minetest.register_decoration(translate_biome_defs(moretrees.jungletree_biome, "jungletree")) +minetest.register_decoration(translate_biome_defs(moretrees.fir_biome, "fir", 1)) +if minetest.get_modpath("snow") then + minetest.register_decoration(translate_biome_defs(moretrees.fir_biome_snow, "fir", 2)) end +minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome, "poplar", 1)) +minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_2, "poplar", 2)) +minetest.register_decoration(translate_biome_defs(moretrees.poplar_biome_3, "poplar", 3)) +minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome, "poplar_small", 4)) +minetest.register_decoration(translate_biome_defs(moretrees.poplar_small_biome_2, "poplar_small", 5)) --[[ this is purposefully wrapped in a on mods loaded callback to that it gets the proper ids diff --git a/node_defs.lua b/node_defs.lua index 9c406ed..979656a 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -327,70 +327,66 @@ for i in ipairs(moretrees.treelist) do }, }) - if moretrees.enable_stairs then - if minetest.get_modpath("moreblocks") then + if minetest.get_modpath("moreblocks") then - -- stairsplus:register_all(modname, subname, recipeitem, {fields}) - - stairsplus:register_all( - "moretrees", - treename.."_trunk", - "moretrees:"..treename.."_trunk", - { - groups = { snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2, not_in_creative_inventory=1 }, - tiles = { - "moretrees_"..treename.."_trunk_top.png", - "moretrees_"..treename.."_trunk_top.png", - "moretrees_"..treename.."_trunk.png" - }, - description = moretrees.treedesc[treename].trunk, - drop = treename.."_trunk", - } - ) - - if moretrees.enable_planks then - stairsplus:register_all( - "moretrees", - treename.."_planks", - "moretrees:"..treename.."_planks", - { - groups = { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, not_in_creative_inventory=1 }, - tiles = { "moretrees_"..treename.."_wood.png" }, - description = moretrees.treedesc[treename].planks, - drop = treename.."_planks", - } - ) - end - elseif minetest.get_modpath("stairs") then - stairs.register_stair_and_slab( - "moretrees_"..treename.."_trunk", - "moretrees:"..treename.."_trunk", - { snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2 }, - { "moretrees_"..treename.."_trunk_top.png", + stairsplus:register_all( + "moretrees", + treename.."_trunk", + "moretrees:"..treename.."_trunk", + { + groups = { snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2, not_in_creative_inventory=1 }, + tiles = { + "moretrees_"..treename.."_trunk_top.png", "moretrees_"..treename.."_trunk_top.png", "moretrees_"..treename.."_trunk.png" }, - moretrees.treedesc[treename].trunk_stair, - moretrees.treedesc[treename].trunk_slab, + description = moretrees.treedesc[treename].trunk, + drop = treename.."_trunk", + } + ) + + if moretrees.enable_planks then + stairsplus:register_all( + "moretrees", + treename.."_planks", + "moretrees:"..treename.."_planks", + { + groups = { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3, not_in_creative_inventory=1 }, + tiles = { "moretrees_"..treename.."_wood.png" }, + description = moretrees.treedesc[treename].planks, + drop = treename.."_planks", + } + ) + end + elseif minetest.get_modpath("stairs") then + stairs.register_stair_and_slab( + "moretrees_"..treename.."_trunk", + "moretrees:"..treename.."_trunk", + { snappy=1, choppy=2, oddly_breakable_by_hand=1, flammable=2 }, + { "moretrees_"..treename.."_trunk_top.png", + "moretrees_"..treename.."_trunk_top.png", + "moretrees_"..treename.."_trunk.png" + }, + moretrees.treedesc[treename].trunk_stair, + moretrees.treedesc[treename].trunk_slab, + xcompat.sounds.node_sound_wood_defaults() + ) + + if moretrees.enable_planks then + stairs.register_stair_and_slab( + "moretrees_"..treename.."_planks", + "moretrees:"..treename.."_planks", + { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3 }, + { "moretrees_"..treename.."_wood.png" }, + moretrees.treedesc[treename].planks_stair, + moretrees.treedesc[treename].planks_slab, xcompat.sounds.node_sound_wood_defaults() ) - - if moretrees.enable_planks then - stairs.register_stair_and_slab( - "moretrees_"..treename.."_planks", - "moretrees:"..treename.."_planks", - { snappy=1, choppy=2, oddly_breakable_by_hand=2, flammable=3 }, - { "moretrees_"..treename.."_wood.png" }, - moretrees.treedesc[treename].planks_stair, - moretrees.treedesc[treename].planks_slab, - xcompat.sounds.node_sound_wood_defaults() - ) - end - end + end - if minetest.get_modpath("default") and moretrees.enable_fences and moretrees.enable_planks then + if minetest.get_modpath("default") and moretrees.enable_planks then local planks_name = "moretrees:" .. treename .. "_planks" local planks_tile = "moretrees_" .. treename .. "_wood.png" default.register_fence("moretrees:" .. treename .. "_fence", { diff --git a/settings.lua b/settings.lua index 78e4f7c..62b4c14 100644 --- a/settings.lua +++ b/settings.lua @@ -1,30 +1,8 @@ local stg = minetest.settings ---enable/disable different trees -moretrees.enable_apple_tree = stg:get_bool("moretrees.enable_apple_tree", true) -moretrees.enable_oak = stg:get_bool("moretrees.enable_oak", true) -moretrees.enable_sequoia = stg:get_bool("moretrees.enable_sequoia", true) -moretrees.enable_palm = stg:get_bool("moretrees.enable_palm", true) -moretrees.enable_date_palm = stg:get_bool("moretrees.enable_date_palm", true) -moretrees.enable_cedar = stg:get_bool("moretrees.enable_cedar", true) -moretrees.enable_rubber_tree = stg:get_bool("moretrees.enable_rubber_tree", true) -moretrees.enable_willow = stg:get_bool("moretrees.enable_willow", true) -moretrees.enable_birch = stg:get_bool("moretrees.enable_birch", true) -moretrees.enable_spruce = stg:get_bool("moretrees.enable_spruce", true) -moretrees.enable_jungle_tree = stg:get_bool("moretrees.enable_jungle_tree", true) -moretrees.enable_fir = stg:get_bool("moretrees.enable_fir", true) -moretrees.enable_poplar = stg:get_bool("moretrees.enable_poplar", true) -moretrees.enable_beech = stg:get_bool("moretrees.enable_beech", false) - --spawns tree on mapgen as saplings, legacy setting moretrees.spawn_saplings = stg:get_bool("moretrees.spawn_saplings", true) ---turn on/off stair varients of nodes via moreblocks or the stair api -moretrees.enable_stairs = stg:get_bool("moretrees.enable_stairs", true) - --- If this variable is set to true, register fences for moretrees wood -moretrees.enable_fences = stg:get_bool("moretrees.enable_fences", true) - --enable plantlike drawtype for leaves moretrees.plantlike_leaves = stg:get_bool("moretrees.plantlike_leaves", false) @@ -32,22 +10,11 @@ moretrees.plantlike_leaves = stg:get_bool("moretrees.plantlike_leaves", false) -- fall when leaves decay/are dug. moretrees.enable_redefine_apple = stg:get_bool("moretrees.enable_redefine_apple", true) --- Set this to true to enable leaf decay of all trees except the default ones. -moretrees.enable_leafdecay = stg:get_bool("moretrees.enable_leafdecay", true) - -- various related settings to configure leaf decay. -moretrees.leafdecay_delay = tonumber(stg:get("moretrees.leafdecay_delay")) or 2 -moretrees.leafdecay_chance = tonumber(stg:get("moretrees.leafdecay_chance")) or 5 moretrees.leafdecay_radius = tonumber(stg:get("moretrees.leafdecay_radius")) or 5 moretrees.palm_leafdecay_radius = tonumber(stg:get("moretrees.palm_leafdecay_radius")) or 10 moretrees.date_palm_leafdecay_radius = tonumber(stg:get("moretrees.date_palm_leafdecay_radius")) or 14 --- Change these settings if you want default trees to be gradually cut down --- above the elevation where firs normally generate. -moretrees.firs_remove_default_trees = stg:get_bool("moretrees.firs_remove_default_trees", false) -moretrees.firs_remove_interval = tonumber(stg:get("moretrees.firs_remove_interval")) or 2 -moretrees.firs_remove_chance = tonumber(stg:get("moretrees.firs_remove_chance")) or 150 - -- Cocos palm settings moretrees.coconuts_regrow = stg:get_bool("moretrees.coconuts_regrow", true) moretrees.coconuts_convert_existing_palms = stg:get_bool("moretrees.coconuts_convert_existing_palms", true) From 517c9dc516ad5d748859c0e22508d697cddefc51 Mon Sep 17 00:00:00 2001 From: Niklp Date: Fri, 31 May 2024 00:34:01 +0200 Subject: [PATCH 6/8] [no squash] Disable jungletree generation when default isn't available (#43) * Remove unused params from biome_defs * Disable jungletree generation when `default` isn't available --- biome_defs.lua | 154 ------------------------------------------------- init.lua | 4 +- 2 files changed, 3 insertions(+), 155 deletions(-) diff --git a/biome_defs.lua b/biome_defs.lua index 7e4b505..57a9993 100644 --- a/biome_defs.lua +++ b/biome_defs.lua @@ -1,74 +1,36 @@ moretrees.beech_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 8, - seed_diff = 2, - rarity = 50, - max_count = 20, } moretrees.palm_biome = { surface = xcompat.materials.sand, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 5, - seed_diff = 330, min_elevation = -1, max_elevation = 1, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, near_nodes_count = 10, - temp_min = 0.25, - temp_max = -0.15, - rarity = 50, - max_count = 10, } moretrees.date_palm_biome = { surface = xcompat.materials.desert_sand, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 339, min_elevation = -1, max_elevation = 10, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 20, near_nodes_count = 100, - near_nodes_vertical = 20, - temp_min = -0.20, - humidity_max = 0.20, - rarity = 10, - max_count = 30, } moretrees.date_palm_biome_2 = { surface = xcompat.materials.desert_sand, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 340, min_elevation = 11, max_elevation = 30, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 1, near_nodes_count = 1, - near_nodes_vertical = 30, - temp_min = -0.20, - humidity_max = 0.20, - rarity = 10, - max_count = 30, } moretrees.apple_tree_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 331, min_elevation = 1, max_elevation = 10, - temp_min = 0.1, - temp_max = -0.15, - rarity = 75, - max_count = 5, place_on = {xcompat.materials.dirt_with_grass}, biomes = {"deciduous_forest"}, fill_ratio = 0.0001, @@ -76,73 +38,39 @@ moretrees.apple_tree_biome = { moretrees.oak_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 15, - seed_diff = 332, min_elevation = 0, max_elevation = 10, - temp_min = 0.4, - temp_max = 0.2, - rarity = 50, - max_count = 5, fill_ratio = 0.0003 } moretrees.sequoia_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 333, min_elevation = 0, max_elevation = 10, - temp_min = 1, - temp_max = -0.4, - rarity = 90, - max_count = 5, fill_ratio = 0.0001, } moretrees.birch_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 5, - seed_diff = 334, min_elevation = 10, max_elevation = 15, - temp_min = 0.9, - temp_max = 0.3, - rarity = 50, - max_count = 10, fill_ratio = 0.001, } moretrees.willow_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 337, min_elevation = -5, max_elevation = 5, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, near_nodes_count = 5, - rarity = 75, - max_count = 5, } moretrees.rubber_tree_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 338, min_elevation = -5, max_elevation = 5, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, near_nodes_count = 10, - temp_min = -0.15, - rarity = 75, - max_count = 10, } moretrees.jungletree_biome = { @@ -154,157 +82,75 @@ moretrees.jungletree_biome = { "woodsoils:grass_with_leaves_2", "default:dirt_with_rainforest_litter", }, - avoid_nodes = {"moretrees:jungletree_trunk"}, - max_count = 12, - avoid_radius = 3, - rarity = 85, - seed_diff = 329, min_elevation = 1, near_nodes = minetest.get_modpath("default") and {"default:jungletree"} or nil, - near_nodes_size = minetest.get_modpath("default") and 6 or nil, - near_nodes_vertical = minetest.get_modpath("default") and 2 or nil, near_nodes_count = minetest.get_modpath("default") and 1 or nil, - plantlife_limit = -0.9, biomes = {"rainforest", "rainforest_swamp"}, } moretrees.spruce_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 335, min_elevation = 20, - temp_min = 0.9, - temp_max = 0.7, - rarity = 50, - max_count = 5, } moretrees.cedar_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 336, min_elevation = 0, --Added to solve an issue where cedar trees would sometimes spawn deep underground near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, near_nodes_count = 5, - rarity = 50, - max_count = 10, } -- Poplar requires a lot of water. moretrees.poplar_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 6, - seed_diff = 341, min_elevation = 0, max_elevation = 50, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, - near_nodes_vertical = 5, near_nodes_count = 1, - humidity_min = -0.7, - humidity_max = -1, - rarity = 50, - max_count = 15, } --- The humidity requirement it quite restrictive (apparently). -- Spawn an occasional poplar elsewhere. moretrees.poplar_biome_2 = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 6, - seed_diff = 341, min_elevation = 0, max_elevation = 50, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 15, - near_nodes_vertical = 4, near_nodes_count = 10, - humidity_min = 0.1, - humidity_max = -0.6, - rarity = 50, - max_count = 1, } -- Subterranean lakes provide enough water for poplars to grow moretrees.poplar_biome_3 = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 6, - seed_diff = 342, min_elevation = 0, max_elevation = 50, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 1, - near_nodes_vertical = 25, near_nodes_count = 1, - humidity_min = -0.5, - humidity_max = -1, - rarity = 0, - max_count = 30, } moretrees.poplar_small_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 4, - seed_diff = 343, min_elevation = 0, max_elevation = 50, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 10, - near_nodes_vertical = 5, near_nodes_count = 1, - humidity_min = -0.7, - humidity_max = -1, - rarity = 50, - max_count = 10, } moretrees.poplar_small_biome_2 = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 4, - seed_diff = 343, min_elevation = 0, max_elevation = 50, near_nodes = {xcompat.materials.water_source}, - near_nodes_size = 10, - near_nodes_vertical = 4, near_nodes_count = 5, - humidity_min = 0.1, - humidity_max = -0.6, - rarity = 50, - max_count = 3, } moretrees.fir_biome = { surface = xcompat.materials.dirt_with_grass, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 359, min_elevation = 25, - temp_min = 0.9, - temp_max = 0.3, - rarity = 50, - max_count = 10, } moretrees.fir_biome_snow = { surface = {"snow:dirt_with_snow", "snow:snow"}, below_nodes = {xcompat.materials.dirt, xcompat.materials.dirt_with_grass, "snow:dirt_with_snow"}, - avoid_nodes = moretrees.avoidnodes, - avoid_radius = 10, - seed_diff = 359, - rarity = 50, - max_count = 10, - check_air = false, - delete_above = true, - spawn_replace_node = true } diff --git a/init.lua b/init.lua index 11e3760..229ee1f 100644 --- a/init.lua +++ b/init.lua @@ -163,7 +163,9 @@ minetest.register_decoration(translate_biome_defs(moretrees.rubber_tree_biome, " minetest.register_decoration(translate_biome_defs(moretrees.willow_biome, "willow")) minetest.register_decoration(translate_biome_defs(moretrees.birch_biome, "birch")) minetest.register_decoration(translate_biome_defs(moretrees.spruce_biome, "spruce")) -minetest.register_decoration(translate_biome_defs(moretrees.jungletree_biome, "jungletree")) +if minetest.get_modpath("default") then + minetest.register_decoration(translate_biome_defs(moretrees.jungletree_biome, "jungletree")) +end minetest.register_decoration(translate_biome_defs(moretrees.fir_biome, "fir", 1)) if minetest.get_modpath("snow") then minetest.register_decoration(translate_biome_defs(moretrees.fir_biome_snow, "fir", 2)) From 2c891e6c25753515ae15f9a453ae37a6cc65921b Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 23 Jun 2024 22:11:39 -0400 Subject: [PATCH 7/8] fix https://github.com/mt-mods/xcompat/issues/29 - restore proper check for voxelgarden --- settings.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/settings.lua b/settings.lua index 62b4c14..f84fd29 100644 --- a/settings.lua +++ b/settings.lua @@ -50,4 +50,8 @@ moretrees.grow_legacy_saplings = stg:get_bool("moretrees.grow_legacy_saplings", moretrees.decay_leaves_as_items = stg:get_bool("moretrees.decay_leaves_as_items", false) -- this is an internal setting for games that only have one type of planks -moretrees.enable_planks = xcompat.gameid ~= "voxelgarden" \ No newline at end of file +if type(minetest.get_game_info) == "function" then + moretrees.enable_planks = minetest.get_game_info().id~="voxelgarden" +else + moretrees.enable_planks = true +end \ No newline at end of file From 458536dbe674fdeda1afee96a0f35f94675899f6 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:41:48 -0400 Subject: [PATCH 8/8] switch to using xcompat (#46) * switch to using xcompat * fix readme * fix dumb mistake --- README.md | 3 ++- node_defs.lua | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 68fd56a..0bab3c3 100644 --- a/README.md +++ b/README.md @@ -8,4 +8,5 @@ jungle trees mod, and big contributions by RealBadAngel. Brought together into one mod and made L-systems compatible by Vanessa Ezekowitz. -Dependencies: `default` +Dependencies: `xcompat` +see mod.conf for more diff --git a/node_defs.lua b/node_defs.lua index 979656a..be6e934 100644 --- a/node_defs.lua +++ b/node_defs.lua @@ -445,7 +445,7 @@ for i in ipairs(moretrees.treelist) do groups = regular_groups, sounds = xcompat.sounds.node_sound_default(), on_place = function(itemstack, placer, pointed_thing) - itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, + itemstack = xcompat.functions.sapling_on_place(itemstack, placer, pointed_thing, "moretrees:" ..treename.. "_sapling", -- minp, maxp to be checked, relative to sapling pos -- minp_relative.y = 1 because sapling pos has been checked @@ -505,7 +505,7 @@ for i in ipairs(moretrees.treelist) do sounds = xcompat.sounds.node_sound_default(), drop = "moretrees:"..treename.."_sapling", on_place = function(itemstack, placer, pointed_thing) - itemstack = default.sapling_on_place(itemstack, placer, pointed_thing, + itemstack = xcompat.functions.sapling_on_place(itemstack, placer, pointed_thing, "moretrees:" ..treename.. "_sapling_ongen", -- minp, maxp to be checked, relative to sapling pos -- minp_relative.y = 1 because sapling pos has been checked