2014-08-12 21:08:11 +02:00
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- Ferns - Giant Tree Fern 0.1.1
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- by Mossmanikin
|
2018-02-18 01:28:43 +01:00
|
|
|
-- Contains code from: biome_lib
|
2014-08-12 21:08:11 +02:00
|
|
|
-- Looked at code from: 4seasons, default
|
2017-08-03 15:02:56 +02:00
|
|
|
-- Supports: vines
|
2014-08-12 21:08:11 +02:00
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
|
2014-08-22 09:07:27 +02:00
|
|
|
assert(abstract_ferns.config.enable_giant_treefern == true)
|
|
|
|
|
2017-08-03 15:02:56 +02:00
|
|
|
-- support for i18n
|
|
|
|
local S = plantlife_i18n.gettext
|
2014-08-12 21:08:11 +02:00
|
|
|
-- lot of code, lot to load
|
|
|
|
|
|
|
|
abstract_ferns.grow_giant_tree_fern = function(pos)
|
2019-04-12 00:10:44 +02:00
|
|
|
local pos_aux = {x = pos.x, y = pos.y + 1, z = pos.z}
|
|
|
|
local name = minetest.get_node(pos_aux).name
|
|
|
|
if name ~= "air" and name ~= "ferns:sapling_giant_tree_fern"
|
|
|
|
and name ~= "default:junglegrass" then
|
2014-08-20 08:41:43 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
local size = math.random(12,16) -- min of range must be >= 4
|
2017-08-03 15:02:56 +02:00
|
|
|
|
2014-08-20 10:00:59 +02:00
|
|
|
local leafchecks = {
|
|
|
|
{
|
|
|
|
direction = 3,
|
|
|
|
positions = {
|
|
|
|
{x = pos.x + 1, y = pos.y + size - 1, z = pos.z },
|
|
|
|
{x = pos.x + 2, y = pos.y + size , z = pos.z },
|
|
|
|
{x = pos.x + 3, y = pos.y + size - 1, z = pos.z },
|
|
|
|
{x = pos.x + 4, y = pos.y + size - 2, z = pos.z }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
direction = 1,
|
|
|
|
positions = {
|
|
|
|
{x = pos.x - 1, y = pos.y + size - 1, z = pos.z },
|
|
|
|
{x = pos.x - 2, y = pos.y + size, z = pos.z },
|
|
|
|
{x = pos.x - 3, y = pos.y + size - 1, z = pos.z },
|
|
|
|
{x = pos.x - 4, y = pos.y + size - 2, z = pos.z }
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
direction = 2,
|
|
|
|
positions = {
|
|
|
|
{x = pos.x , y = pos.y + size - 1, z = pos.z + 1},
|
|
|
|
{x = pos.x , y = pos.y + size , z = pos.z + 2},
|
|
|
|
{x = pos.x , y = pos.y + size - 1, z = pos.z + 3},
|
|
|
|
{x = pos.x , y = pos.y + size - 2, z = pos.z + 4}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
direction = 0,
|
|
|
|
positions = {
|
|
|
|
{x = pos.x , y = pos.y + size - 1, z = pos.z - 1},
|
|
|
|
{x = pos.x , y = pos.y + size , z = pos.z - 2},
|
|
|
|
{x = pos.x , y = pos.y + size - 1, z = pos.z - 3},
|
|
|
|
{x = pos.x , y = pos.y + size - 2, z = pos.z - 4}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-15 02:23:33 +01:00
|
|
|
local brk = false
|
2014-08-20 08:41:43 +02:00
|
|
|
for i = 1, size-3 do
|
2019-04-12 00:10:44 +02:00
|
|
|
pos_aux.y = pos.y + i
|
|
|
|
local name = minetest.get_node(pos_aux).name
|
|
|
|
if not (name == "air" or (i == 1 and name == "ferns:sapling_giant_tree_fern")) then
|
2017-03-15 02:23:33 +01:00
|
|
|
brk = true
|
|
|
|
break
|
|
|
|
end
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node({x = pos.x, y = pos.y + i, z = pos.z}, {name="ferns:fern_trunk_big"})
|
2014-08-20 08:41:43 +02:00
|
|
|
end
|
2017-03-15 02:23:33 +01:00
|
|
|
if not brk then
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node({x = pos.x, y = pos.y + size-2, z = pos.z}, {name="ferns:fern_trunk_big_top"})
|
|
|
|
minetest.swap_node({x = pos.x, y = pos.y + size-1, z = pos.z}, {name="ferns:tree_fern_leaves_giant"})
|
2014-08-14 09:31:02 +02:00
|
|
|
|
2017-03-15 02:23:33 +01:00
|
|
|
-- all the checking for air below is to prevent some ugly bugs (incomplete trunks of neighbouring trees), it's a bit slower, but worth the result
|
2014-08-20 08:41:43 +02:00
|
|
|
|
2017-03-15 02:23:33 +01:00
|
|
|
-- assert(#leafchecks == 4)
|
|
|
|
for i = 1, 4 do
|
|
|
|
local positions = leafchecks[i].positions
|
|
|
|
local rot = leafchecks[i].direction
|
|
|
|
local endpos = 4 -- If the loop below adds all intermediate leaves then the "terminating" leaf will be at positions[4]
|
|
|
|
-- assert(#positions == 4)
|
|
|
|
-- add leaves so long as the destination nodes are air
|
|
|
|
for j = 1, 3 do
|
|
|
|
if minetest.get_node(positions[j]).name == "air" then
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node(positions[j], {name="ferns:tree_fern_leave_big"})
|
2017-03-15 02:23:33 +01:00
|
|
|
else
|
|
|
|
endpos = j
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- add the terminating leaf if required and possible
|
|
|
|
if endpos == 4 and minetest.get_node(positions[endpos]).name == "air" then
|
2018-10-25 16:27:54 +02:00
|
|
|
minetest.swap_node(positions[endpos], {name="ferns:tree_fern_leave_big_end", param2=rot})
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
end
|
2014-08-20 08:41:43 +02:00
|
|
|
end
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN LEAVES
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-20 13:51:32 +02:00
|
|
|
minetest.register_node("ferns:tree_fern_leaves_giant", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Tree Fern Crown (Dicksonia)"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
2017-06-16 20:16:18 +02:00
|
|
|
visual_scale = math.sqrt(11),
|
2014-08-19 01:05:27 +02:00
|
|
|
wield_scale = {x=0.175, y=0.175, z=0.175},
|
2014-08-12 21:08:11 +02:00
|
|
|
paramtype = "light",
|
|
|
|
tiles = {"ferns_fern_tree_giant.png"},
|
|
|
|
inventory_image = "ferns_fern_tree.png",
|
|
|
|
walkable = false,
|
|
|
|
groups = {
|
|
|
|
snappy=3,
|
|
|
|
flammable=2,
|
|
|
|
attached_node=1,
|
|
|
|
not_in_creative_inventory=1
|
|
|
|
},
|
|
|
|
drop = {
|
2015-06-21 10:39:41 +02:00
|
|
|
max_items = 2,
|
2014-08-12 21:08:11 +02:00
|
|
|
items = {
|
2015-06-21 10:39:41 +02:00
|
|
|
{
|
|
|
|
-- occasionally, drop a second sapling instead of leaves
|
|
|
|
-- (extra saplings can also be obtained by replanting and
|
|
|
|
-- reharvesting leaves)
|
|
|
|
items = {"ferns:sapling_giant_tree_fern"},
|
|
|
|
rarity = 10,
|
|
|
|
},
|
2014-08-12 21:08:11 +02:00
|
|
|
{
|
|
|
|
items = {"ferns:sapling_giant_tree_fern"},
|
|
|
|
},
|
|
|
|
{
|
2014-08-20 13:51:32 +02:00
|
|
|
items = {"ferns:tree_fern_leaves_giant"},
|
2014-08-12 21:08:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN LEAVE PART
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-20 13:51:32 +02:00
|
|
|
minetest.register_node("ferns:tree_fern_leave_big", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Giant Tree Fern Leaves"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "raillike",
|
|
|
|
paramtype = "light",
|
|
|
|
tiles = {
|
|
|
|
"ferns_tree_fern_leave_big.png",
|
|
|
|
},
|
|
|
|
walkable = false,
|
|
|
|
groups = {
|
|
|
|
snappy=3,
|
|
|
|
flammable=2,
|
|
|
|
attached_node=1,
|
|
|
|
not_in_creative_inventory=1
|
|
|
|
},
|
|
|
|
drop = "",
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN LEAVE END
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-20 13:51:32 +02:00
|
|
|
minetest.register_node("ferns:tree_fern_leave_big_end", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Giant Tree Fern Leave End"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
paramtype2 = "facedir",
|
|
|
|
tiles = { "ferns_tree_fern_leave_big_end.png" },
|
|
|
|
walkable = false,
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
-- {left, bottom, front, right, top, back }
|
|
|
|
fixed = {-1/2, -1/2, 1/2, 1/2, 33/64, 1/2},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/2, -1/2, 1/2, 1/2, 33/64, 1/2},
|
|
|
|
},
|
|
|
|
groups = {
|
|
|
|
snappy=3,
|
|
|
|
flammable=2,
|
|
|
|
attached_node=1,
|
|
|
|
not_in_creative_inventory=1
|
|
|
|
},
|
|
|
|
drop = "",
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN TRUNK TOP
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
minetest.register_node("ferns:fern_trunk_big_top", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Giant Fern Trunk"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
tiles = {
|
|
|
|
"ferns_fern_trunk_big_top.png^ferns_tree_fern_leave_big_cross.png",
|
|
|
|
"ferns_fern_trunk_big_top.png^ferns_tree_fern_leave_big_cross.png",
|
|
|
|
"ferns_fern_trunk_big.png"
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
-- {left, bottom, front, right, top, back }
|
|
|
|
fixed = {
|
|
|
|
{-1/2, 33/64, -1/2, 1/2, 33/64, 1/2},
|
|
|
|
{-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
|
|
|
|
},
|
|
|
|
groups = {
|
|
|
|
tree=1,
|
|
|
|
choppy=2,
|
|
|
|
oddly_breakable_by_hand=2,
|
|
|
|
flammable=3,
|
|
|
|
wood=1,
|
|
|
|
not_in_creative_inventory=1,
|
|
|
|
leafdecay=3 -- to support vines
|
|
|
|
},
|
|
|
|
drop = "ferns:fern_trunk_big",
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN TRUNK
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
minetest.register_node("ferns:fern_trunk_big", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Giant Fern Trunk"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "nodebox",
|
|
|
|
paramtype = "light",
|
|
|
|
tiles = {
|
|
|
|
"ferns_fern_trunk_big_top.png",
|
|
|
|
"ferns_fern_trunk_big_top.png",
|
|
|
|
"ferns_fern_trunk_big.png"
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
|
|
|
|
},
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-1/4, -1/2, -1/4, 1/4, 1/2, 1/4},
|
|
|
|
},
|
|
|
|
groups = {tree=1,choppy=2,oddly_breakable_by_hand=2,flammable=3,wood=1},
|
|
|
|
sounds = default.node_sound_wood_defaults(),
|
|
|
|
after_destruct = function(pos,oldnode)
|
|
|
|
local node = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
|
2017-08-03 15:02:56 +02:00
|
|
|
if node.name == "ferns:fern_trunk_big" or node.name == "ferns:fern_trunk_big_top" then
|
|
|
|
minetest.dig_node({x=pos.x,y=pos.y+1,z=pos.z})
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GIANT TREE FERN SAPLING
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
minetest.register_node("ferns:sapling_giant_tree_fern", {
|
2017-08-03 15:02:56 +02:00
|
|
|
description = S("Giant Tree Fern Sapling"),
|
2014-08-12 21:08:11 +02:00
|
|
|
drawtype = "plantlike",
|
|
|
|
paramtype = "light",
|
|
|
|
tiles = {"ferns_sapling_tree_fern_giant.png"},
|
|
|
|
inventory_image = "ferns_sapling_tree_fern_giant.png",
|
|
|
|
walkable = false,
|
|
|
|
groups = {snappy=3,flammable=2,flora=1,attached_node=1},
|
|
|
|
sounds = default.node_sound_leaves_defaults(),
|
|
|
|
selection_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {-7/16, -1/2, -7/16, 7/16, 0, 7/16},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
-- abm
|
|
|
|
minetest.register_abm({
|
|
|
|
nodenames = "ferns:sapling_giant_tree_fern",
|
|
|
|
interval = 1000,
|
|
|
|
chance = 4,
|
|
|
|
action = function(pos, node, _, _)
|
|
|
|
abstract_ferns.grow_giant_tree_fern({x = pos.x, y = pos.y-1, z = pos.z})
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------------------------
|
|
|
|
-- GENERATE GIANT TREE FERN
|
|
|
|
-----------------------------------------------------------------------------------------------
|
2014-08-20 10:35:08 +02:00
|
|
|
|
2014-08-12 21:08:11 +02:00
|
|
|
-- in jungles
|
2014-08-22 09:04:34 +02:00
|
|
|
if abstract_ferns.config.enable_giant_treeferns_in_jungle == true then
|
2015-08-09 16:11:30 +02:00
|
|
|
biome_lib:register_generate_plant({
|
2014-08-20 10:35:08 +02:00
|
|
|
surface = {
|
|
|
|
"default:dirt_with_grass",
|
2018-03-17 21:37:02 +01:00
|
|
|
"default:dirt_with_rainforest_litter", -- minetest >= 0.4.16
|
2014-08-20 10:35:08 +02:00
|
|
|
"default:sand",
|
|
|
|
"default:desert_sand"--,
|
|
|
|
--"dryplants:grass_short"
|
|
|
|
},
|
|
|
|
max_count = 12,--27,
|
|
|
|
avoid_nodes = {"group:tree"},
|
|
|
|
avoid_radius = 3,--4,
|
|
|
|
rarity = 85,
|
|
|
|
seed_diff = 329,
|
|
|
|
min_elevation = 1,
|
|
|
|
near_nodes = {"default:jungletree"},
|
|
|
|
near_nodes_size = 6,
|
|
|
|
near_nodes_vertical = 2,--4,
|
|
|
|
near_nodes_count = 1,
|
|
|
|
plantlife_limit = -0.9,
|
2014-08-12 21:08:11 +02:00
|
|
|
},
|
2014-08-20 10:35:08 +02:00
|
|
|
abstract_ferns.grow_giant_tree_fern
|
|
|
|
)
|
2014-08-12 21:08:11 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- for oases & tropical beaches
|
2014-08-22 09:04:34 +02:00
|
|
|
if abstract_ferns.config.enable_giant_treeferns_in_oases == true then
|
2015-08-09 16:11:30 +02:00
|
|
|
biome_lib:register_generate_plant({
|
2014-08-20 10:35:08 +02:00
|
|
|
surface = {
|
|
|
|
"default:sand"--,
|
|
|
|
--"default:desert_sand"
|
|
|
|
},
|
|
|
|
max_count = 10,--27,
|
|
|
|
rarity = 90,
|
|
|
|
seed_diff = 329,
|
|
|
|
neighbors = {"default:desert_sand"},
|
|
|
|
ncount = 1,
|
|
|
|
min_elevation = 1,
|
2018-03-17 21:37:02 +01:00
|
|
|
near_nodes = {"default:water_source", "default:river_water_source"},
|
2014-08-20 10:35:08 +02:00
|
|
|
near_nodes_size = 2,
|
|
|
|
near_nodes_vertical = 1,
|
|
|
|
near_nodes_count = 1,
|
|
|
|
plantlife_limit = -0.9,
|
|
|
|
humidity_max = -1.0,
|
|
|
|
humidity_min = 1.0,
|
|
|
|
temp_max = -1.0,
|
|
|
|
temp_min = 1.0,
|
2014-08-12 21:08:11 +02:00
|
|
|
},
|
2014-08-20 10:35:08 +02:00
|
|
|
abstract_ferns.grow_giant_tree_fern
|
|
|
|
)
|
2014-08-13 05:19:51 +02:00
|
|
|
end
|