GloopMaster's jungletree fixes.
Jungle Trees use "default:jungletree" instead of custom node. Wild Jungle Tree saplings grow faster, while placed ones grow slower. Jungle Tree sapling image was touched up. Jungle Trees were given their own leaves, which drop Jungle Tree saplings.master
parent
e871707fb5
commit
5461e0ea46
|
@ -1,4 +0,0 @@
|
|||
jungletree
|
||||
==========
|
||||
|
||||
Adds jungle trees to minetest. Jungle trees spawn near water sources
|
|
@ -0,0 +1,8 @@
|
|||
GloopMaster's Jungle Tree fix.
|
||||
|
||||
Adds the following:
|
||||
|
||||
Jungle Trees use "default:jungletree" instead of custom node.
|
||||
Wild Jungle Tree saplings grow faster, while placed ones grow slower.
|
||||
Jungle Tree sapling image was touched up.
|
||||
Jungle Trees were given their own leaves, which drop Jungle Tree saplings.
|
307
init.lua
307
init.lua
|
@ -1,158 +1,149 @@
|
|||
minetest.register_node("jungletree:sapling", {
|
||||
description = "jungletree sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"jungletree_sapling.png"},
|
||||
inventory_image = "jungletree_sapling.png",
|
||||
wield_image = "default_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=2,dig_immediate=3,flammable=2},
|
||||
})
|
||||
|
||||
minetest.register_node("jungletree:tree", {
|
||||
description = "Tree",
|
||||
tiles = {"default_tree_top.png", "default_tree_top.png", "jungletree_bark.png"},
|
||||
is_ground_content = true,
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
})
|
||||
|
||||
|
||||
local function add_tree_branch(pos)
|
||||
|
||||
minetest.env:add_node(pos, {name="jungletree:tree"})
|
||||
|
||||
for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||
|
||||
for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||
|
||||
local p = {x=pos.x+i, y=pos.y, z=pos.z+k}
|
||||
local n = minetest.env:get_node(p)
|
||||
|
||||
if (n.name=="air") then
|
||||
|
||||
minetest.env:add_node(p, {name="default:leaves"})
|
||||
|
||||
end
|
||||
|
||||
local chance = math.abs(i+k)
|
||||
|
||||
if (chance < 1) then
|
||||
|
||||
p = {x=pos.x+i, y=pos.y+1, z=pos.z+k}
|
||||
n = minetest.env:get_node(p)
|
||||
|
||||
if (n.name=="air") then
|
||||
minetest.env:add_node(p, {name="default:leaves"})
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
minetest.register_abm({
|
||||
nodenames = {"jungletree:sapling"},
|
||||
interval = 10,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
|
||||
local height = 5 + math.random(15)
|
||||
|
||||
if height < 10 then
|
||||
|
||||
for i = height, -1, -1 do
|
||||
|
||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||
minetest.env:add_node(p, {name="jungletree:tree"})
|
||||
|
||||
if i == height then
|
||||
|
||||
add_tree_branch({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z})
|
||||
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z})
|
||||
add_tree_branch({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1})
|
||||
|
||||
end
|
||||
|
||||
if height <= 0 then
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="jungletree:tree"})
|
||||
end
|
||||
|
||||
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||
add_tree_branch(branch_pos)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
for i = height, -2, -1 do
|
||||
|
||||
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||
|
||||
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||
add_tree_branch(branch_pos)
|
||||
|
||||
end
|
||||
|
||||
if i < math.random(0,1) then
|
||||
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="jungletree:tree"})
|
||||
|
||||
end
|
||||
|
||||
if i == height then
|
||||
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+1})
|
||||
add_tree_branch({x=pos.x+2, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-2})
|
||||
add_tree_branch({x=pos.x-1, y=pos.y+i, z=pos.z})
|
||||
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+2})
|
||||
add_tree_branch({x=pos.x+3, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-3})
|
||||
add_tree_branch({x=pos.x-2, y=pos.y+i, z=pos.z})
|
||||
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z})
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z})
|
||||
|
||||
else
|
||||
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="jungletree:tree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="jungletree:tree"})
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
--function anti_generate(node, surfaces, minp, maxp, height_min, height_max, spread, habitat_size, habitat_nodes)
|
||||
|
||||
|
||||
|
||||
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
|
||||
generate("jungletree:sapling", {"default:dirt_with_grass"}, minp, maxp, 0, 20, 10, 50, {"default:water_source"},30,{"default:desert_sand"})
|
||||
|
||||
end)
|
||||
|
||||
print("[Jungletree] Loaded!")
|
||||
minetest.register_node("jungletree:sapling", {
|
||||
description = "Jungle Tree Sapling",
|
||||
drawtype = "plantlike",
|
||||
visual_scale = 1.0,
|
||||
tiles = {"jungletree_sapling.png"},
|
||||
inventory_image = "jungletree_sapling.png",
|
||||
wield_image = "default_sapling.png",
|
||||
paramtype = "light",
|
||||
walkable = false,
|
||||
groups = {snappy=2,dig_immediate=3,flammable=2},
|
||||
})
|
||||
|
||||
if minetest.setting_get("new_style_leaves") == true then
|
||||
leavesimg = {"jungletree_leaves_trans.png"}
|
||||
else
|
||||
leavesimg = {"jungletree_leaves.png"}
|
||||
end
|
||||
|
||||
minetest.register_node("jungletree:leaves", {
|
||||
description = "Jungle Tree Leaves",
|
||||
drawtype = "glasslike",
|
||||
tiles = leavesimg,
|
||||
paramtype = "light",
|
||||
groups = {snappy=3, leafdecay=3, flammable=2},
|
||||
drop = {
|
||||
max_items = 1,
|
||||
items = {
|
||||
{
|
||||
-- player will get sapling with 1/20 chance
|
||||
items = {'jungletree:sapling'},
|
||||
rarity = 20,
|
||||
},
|
||||
{
|
||||
-- player will get leaves only if he get no saplings,
|
||||
-- this is because max_items is 1
|
||||
items = {'jungletree:leaves'},
|
||||
}
|
||||
}
|
||||
},
|
||||
sounds = default.node_sound_leaves_defaults(),
|
||||
})
|
||||
|
||||
--[[ minetest.register_node("jungletree:tree", {
|
||||
description = "Tree",
|
||||
tiles = {"default_tree_top.png",
|
||||
"default_tree_top.png",
|
||||
"jungletree_bark.png"},
|
||||
is_ground_content = true,
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
}) --]]
|
||||
|
||||
minetest.register_alias("jungletree:tree", "default:jungletree")
|
||||
|
||||
minetest.register_node(":default:jungletree", {
|
||||
description = "Jungle Tree",
|
||||
tiles = {"default_jungletree_top.png", "default_jungletree_top.png", "default_jungletree.png"},
|
||||
is_ground_content = true,
|
||||
groups = {tree=1,snappy=1,choppy=2,oddly_breakable_by_hand=1,flammable=2},
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
local function add_tree_branch(pos)
|
||||
minetest.env:add_node(pos, {name="default:jungletree"})
|
||||
for i = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||
for k = math.floor(math.random(2)), -math.floor(math.random(2)), -1 do
|
||||
local p = {x=pos.x+i, y=pos.y, z=pos.z+k}
|
||||
local n = minetest.env:get_node(p)
|
||||
if (n.name=="air") then
|
||||
minetest.env:add_node(p, {name="jungletree:leaves"})
|
||||
end
|
||||
local chance = math.abs(i+k)
|
||||
if (chance < 1) then
|
||||
p = {x=pos.x+i, y=pos.y+1, z=pos.z+k}
|
||||
n = minetest.env:get_node(p)
|
||||
if (n.name=="air") then
|
||||
minetest.env:add_node(p, {name="jungletree:leaves"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
minetest.register_abm({
|
||||
nodenames = {"jungletree:sapling"},
|
||||
interval = 1,
|
||||
chance = 1,
|
||||
action = function(pos, node)
|
||||
local height = 5 + math.random(15)
|
||||
if height < 10 then
|
||||
for i = height, -1, -1 do
|
||||
local p = {x=pos.x, y=pos.y+i, z=pos.z}
|
||||
minetest.env:add_node(p, {name="default:jungletree"})
|
||||
if i == height then
|
||||
add_tree_branch({x=pos.x, y=pos.y+height+math.random(0, 1), z=pos.z})
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z})
|
||||
add_tree_branch({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1})
|
||||
end
|
||||
if height <= 0 then
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z+1}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x-1, y=pos.y+i-math.random(2), z=pos.z}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i-math.random(2), z=pos.z-1}, {name="default:jungletree"})
|
||||
end
|
||||
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||
add_tree_branch(branch_pos)
|
||||
end
|
||||
end
|
||||
else
|
||||
for i = height, -2, -1 do
|
||||
if (math.sin(i/height*i) < 0.2 and i > 3 and math.random(0,2) < 1.5) then
|
||||
branch_pos = {x=pos.x+math.random(0,1), y=pos.y+i, z=pos.z-math.random(0,1)}
|
||||
add_tree_branch(branch_pos)
|
||||
end
|
||||
if i < math.random(0,1) then
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z+1}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x+2, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-2}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x-1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||
end
|
||||
if i == height then
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+1})
|
||||
add_tree_branch({x=pos.x+2, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-2})
|
||||
add_tree_branch({x=pos.x-1, y=pos.y+i, z=pos.z})
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z+2})
|
||||
add_tree_branch({x=pos.x+3, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-3})
|
||||
add_tree_branch({x=pos.x-2, y=pos.y+i, z=pos.z})
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z})
|
||||
add_tree_branch({x=pos.x+1, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z-1})
|
||||
add_tree_branch({x=pos.x, y=pos.y+i, z=pos.z})
|
||||
else
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x+1, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z-1}, {name="default:jungletree"})
|
||||
minetest.env:add_node({x=pos.x, y=pos.y+i, z=pos.z}, {name="default:jungletree"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end,})
|
||||
|
||||
--function anti_generate(node, surfaces, minp, maxp, height_min, height_max, spread, habitat_size, habitat_nodes)
|
||||
minetest.register_on_generated(function(minp, maxp, seed)
|
||||
generate("jungletree:sapling", {"default:dirt_with_grass"}, minp, maxp, 0, 20, 10, 50, {"default:water_source"},30,{"default:desert_sand"})
|
||||
end)
|
||||
print("[Jungletree] Loaded!")
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 249 B |
Binary file not shown.
After Width: | Height: | Size: 251 B |
Binary file not shown.
Before Width: | Height: | Size: 278 B After Width: | Height: | Size: 215 B |
Loading…
Reference in New Issue