diff --git a/README.md b/README.md index 972fc2c..f3e6934 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,7 @@ who helped make this mod bigger and better throughout it's release :) - Switch ethereal coral to new plantlike_rooted drawtype (thanks Niklp) - Switch seaweed to new plantlike_rooted drawtype (thanks Niklp) - Added 'ethereal.logs' setting that adds decorative fallen tree logs to biomes + - Added 'ethereal.sapling_protection_check' setting to use default sapling placement checks ### 1.30 - New fish textures by SirroBzeroone and BlueTangs Rock diff --git a/init.lua b/init.lua index a8bab87..19cdf2e 100644 --- a/init.lua +++ b/init.lua @@ -7,7 +7,7 @@ ]] -ethereal = {version = "20240310"} +ethereal = {version = "20240316"} local function setting(stype, name, default) @@ -110,6 +110,7 @@ dofile(path .. "/dirt.lua") dofile(path .. "/food.lua") dofile(path .. "/wood.lua") dofile(path .. "/leaves.lua") +dofile(path .. "/schems.lua") dofile(path .. "/sapling.lua") dofile(path .. "/fishing.lua") dofile(path .. "/extra.lua") @@ -122,7 +123,6 @@ end dofile(path .. "/biomes.lua") dofile(path .. "/ores.lua") -dofile(path .. "/schems.lua") dofile(path .. "/decor.lua") dofile(path .. "/compatibility.lua") dofile(path .. "/stairs.lua") diff --git a/sapling.lua b/sapling.lua index cf0091b..b95befc 100644 --- a/sapling.lua +++ b/sapling.lua @@ -1,6 +1,24 @@ local S = ethereal.translate +-- Sapling protection check function +local sapling_protection_check = minetest.settings:get_bool( + "ethereal.sapling_protection_check", false) + +local function prepare_on_place(itemstack, placer, pointed_thing, name, w, h) + + if sapling_protection_check then + + -- check if grown tree area intersects any players protected area + return default.sapling_on_place(itemstack, placer, pointed_thing, + name, {x = -w, y = 1, z = -w}, {x = w, y = h, z = w}, 4) + end + + -- place normally + return minetest.item_place_node(itemstack, placer, pointed_thing) +end + + -- Basandra Bush Sapling minetest.register_node("ethereal:basandra_bush_sapling", { description = S("Basandra Bush Sapling"), @@ -18,9 +36,14 @@ minetest.register_node("ethereal:basandra_bush_sapling", { groups = {snappy = 2, dig_immediate = 3, attached_node = 1, ethereal_sapling = 1, sapling = 1}, sounds = default.node_sound_leaves_defaults(), - grown_height = 2 + grown_height = 2, + on_place = function(itemstack, placer, pointed_thing) + return prepare_on_place(itemstack, placer, pointed_thing, + "ethereal:basandra_bush_sapling", 1, 2) + end }) + -- Bamboo Sprout minetest.register_node("ethereal:bamboo_sprout", { description = S("Bamboo Sprout"), @@ -41,12 +64,16 @@ minetest.register_node("ethereal:bamboo_sprout", { fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 0, 4 / 16} }, on_use = minetest.item_eat(2), - grown_height = 11 + grown_height = 11, + on_place = function(itemstack, placer, pointed_thing) + return prepare_on_place(itemstack, placer, pointed_thing, + "ethereal:bamboo_sprout", 1, 18) + end }) -- Register Saplings -local register_sapling = function(name, desc, texture, height) +local register_sapling = function(name, desc, texture, width, height) minetest.register_node(name .. "_sapling", { description = S(desc .. " Tree Sapling"), @@ -67,25 +94,29 @@ local register_sapling = function(name, desc, texture, height) ethereal_sapling = 1, attached_node = 1, sapling = 1 }, sounds = default.node_sound_leaves_defaults(), - grown_height = height + grown_height = height, + on_place = function(itemstack, placer, pointed_thing) + return prepare_on_place(itemstack, placer, pointed_thing, + name .. "_sapling", width, height) + end }) end -register_sapling("ethereal:willow", "Willow", "ethereal_willow_sapling", 14) -register_sapling("ethereal:yellow_tree", "Healing", "ethereal_yellow_tree_sapling", 19) -register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree_sapling", 7) -register_sapling("ethereal:banana_tree", "Banana", "ethereal_banana_tree_sapling", 8) -register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree_sapling", 19) -register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom_sapling", 11) -register_sapling("ethereal:palm", "Palm", "moretrees_palm_sapling", 9) +register_sapling("ethereal:willow", "Willow", "ethereal_willow_sapling", 5, 14) +register_sapling("ethereal:yellow_tree", "Healing", "ethereal_yellow_tree_sapling", 4, 19) +register_sapling("ethereal:big_tree", "Big", "ethereal_big_tree_sapling", 4, 7) +register_sapling("ethereal:banana_tree", "Banana", "ethereal_banana_tree_sapling", 3, 8) +register_sapling("ethereal:frost_tree", "Frost", "ethereal_frost_tree_sapling", 4, 19) +register_sapling("ethereal:mushroom", "Mushroom", "ethereal_mushroom_sapling", 4, 11) +register_sapling("ethereal:palm", "Palm", "moretrees_palm_sapling", 4, 9) register_sapling("ethereal:giant_redwood", "Giant Redwood", - "ethereal_giant_redwood_sapling", 33) -register_sapling("ethereal:redwood", "Redwood", "ethereal_redwood_sapling", 21) -register_sapling("ethereal:orange_tree", "Orange", "ethereal_orange_tree_sapling", 6) -register_sapling("ethereal:birch", "Birch", "moretrees_birch_sapling", 7) -register_sapling("ethereal:sakura", "Sakura", "ethereal_sakura_sapling", 10) -register_sapling("ethereal:lemon_tree", "Lemon", "ethereal_lemon_tree_sapling", 7) -register_sapling("ethereal:olive_tree", "Olive", "ethereal_olive_tree_sapling", 10) + "ethereal_giant_redwood_sapling", 7, 33) +register_sapling("ethereal:redwood", "Redwood", "ethereal_redwood_sapling", 4, 21) +register_sapling("ethereal:orange_tree", "Orange", "ethereal_orange_tree_sapling", 2, 6) +register_sapling("ethereal:birch", "Birch", "moretrees_birch_sapling", 2, 7) +register_sapling("ethereal:sakura", "Sakura", "ethereal_sakura_sapling", 4, 10) +register_sapling("ethereal:lemon_tree", "Lemon", "ethereal_lemon_tree_sapling", 2, 7) +register_sapling("ethereal:olive_tree", "Olive", "ethereal_olive_tree_sapling", 3, 10) local add_tree = function (pos, ofx, ofy, ofz, schem, replace) @@ -307,3 +338,4 @@ minetest.register_craft({ output = "ethereal:giant_redwood_sapling", recipe = {{"ethereal:redwood_sapling", "ethereal:redwood_sapling"}} }) + diff --git a/settings.conf_example b/settings.conf_example index 1668a69..7eda301 100644 --- a/settings.conf_example +++ b/settings.conf_example @@ -42,3 +42,4 @@ ethereal.sealife = 1 -- Enable coral and seaweed ethereal.reefs = 1 -- Enable new coral reefs in default ethereal.sakura = 1 -- Enable sakura biomes with trees ethereal.mediterranean = 1 -- Enable Mediterranean biome + diff --git a/settingtypes.txt b/settingtypes.txt index 9976cde..fa802f8 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -44,3 +44,6 @@ ethereal.flightpotion_duration (Flight Potion Duration) int 300 ethereal.clear_default_biomes (Clear Default Biomes and Decoration) bool true ethereal.abundant_onions (Abundant Onions) bool true + +ethereal.sapling_protection_check (Check for area protection before placing sapling) bool false +