Merge branch 'add_banana_orange_trees' of Xachman/Epic into master

master
NathanS21 2020-07-09 01:20:52 +00:00 committed by Gogs
commit b8e59ecdad
18 changed files with 462 additions and 0 deletions

View File

@ -0,0 +1 @@
default

58
mods/epic_trees/food.lua Normal file
View File

@ -0,0 +1,58 @@
-- Banana (Heals one heart when eaten)
minetest.register_node("epic_trees:banana", {
description = "Banana",
drawtype = "torchlike",
tiles = {"banana_single.png"},
inventory_image = "banana_single.png",
wield_image = "banana_single.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.31, -0.5, -0.31, 0.31, 0.5, 0.31}
},
groups = {
food_banana = 1, fleshy = 3, dig_immediate = 3, flammable = 2,
leafdecay = 1, leafdecay_drop = 1
},
drop = "epic_trees:banana",
on_use = minetest.item_eat(2),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer)
if placer:is_player() then
minetest.set_node(pos, {name = "epic_trees:banana", param2 = 1})
end
end,
})
-- Orange (Heals 2 hearts when eaten)
minetest.register_node("epic_trees:orange", {
description = "Orange",
drawtype = "plantlike",
tiles = {"farming_orange.png"},
inventory_image = "farming_orange.png",
wield_image = "farming_orange.png",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-0.27, -0.37, -0.27, 0.27, 0.44, 0.27}
},
groups = {
food_orange = 1, fleshy = 3, dig_immediate = 3, flammable = 2,
leafdecay = 3, leafdecay_drop = 1
},
drop = "epic_trees:orange",
on_use = minetest.item_eat(4),
sounds = default.node_sound_leaves_defaults(),
after_place_node = function(pos, placer)
if placer:is_player() then
minetest.set_node(pos, {name = "epic_trees:orange", param2 = 1})
end
end,
})

34
mods/epic_trees/init.lua Normal file
View File

@ -0,0 +1,34 @@
--[[
Epic Trees
Created by Xachman
]]
epic_trees = {
}
local path = minetest.get_modpath("epic_trees")
dofile(path .. "/wood.lua")
dofile(path .. "/sapling.lua")
dofile(path .. "/schems.lua")
dofile(path .. "/food.lua")
dofile(path .. "/leaves.lua")
if minetest.get_modpath("lumberjack") and minetest.global_exists("lumberjack") then
lumberjack.register_tree("epic_trees:banana_trunk", "epic_trees:banana_tree_sapling", 1, 3)
end
if minetest.get_modpath("bonemeal") and minetest.global_exists("bonemeal") then
bonemeal:add_sapling({
{"epic_trees:banana_tree_sapling", epic_trees.grow_banana_tree, "soil"},
{"epic_trees:banana_tree_sapling", epic_trees.grow_banana_tree, "sand"},
{"epic_trees:orange_tree_sapling", epic_trees.grow_orange_tree, "soil"},
{"epic_trees:orange_tree_sapling", epic_trees.grow_orange_tree, "sand"}
})
end

View File

@ -0,0 +1,61 @@
local leaftype = "plantlike"
local leafscale = 1.4
-- banana tree leaves
minetest.register_node("epic_trees:bananaleaves", {
description = "Banana Leaves",
drawtype = leaftype,
visual_scale = leafscale,
tiles = {"banana_leaf.png"},
inventory_image = "banana_leaf.png",
wield_image = "banana_leaf.png",
paramtype = "light",
walkable = false,
waving = 1,
groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2},
drop = {
max_items = 1,
items = {
{items = {"epic_trees:banana_tree_sapling"}, rarity = 10},
{items = {"epic_trees:bananaleaves"}}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
default.register_leafdecay({
trunks = {"epic_trees:banana_trunk"},
leaves = {"epic_trees:bananaleaves", "epic_trees:banana"},
radius = 3
})
-- orange tree leaves
minetest.register_node("epic_trees:orange_leaves", {
description = "Orange Leaves",
drawtype = leaftype,
visual_scale = leafscale,
tiles = {"orange_leaves.png"},
inventory_image = "orange_leaves.png",
wield_image = "orange_leaves.png",
paramtype = "light",
walkable = epic_trees.leafwalk,
waving = 1,
groups = {snappy = 3, leafdecay = 3, leaves = 1, flammable = 2},
drop = {
max_items = 1,
items = {
{items = {"epic_trees:orange_tree_sapling"}, rarity = 15},
{items = {"epic_trees:orange_leaves"}}
}
},
sounds = default.node_sound_leaves_defaults(),
after_place_node = default.after_place_leaves,
})
default.register_leafdecay({
trunks = {"default:tree"},
leaves = {"epic_trees:orange_leaves", "epic_trees:orange"},
radius = 3
})

119
mods/epic_trees/sapling.lua Normal file
View File

@ -0,0 +1,119 @@
local add_tree = function (pos, ofx, ofy, ofz, schem, replace)
-- check for schematic
if not schem then
print ("Schematic not found")
return
end
-- remove sapling and place schematic
minetest.swap_node(pos, {name = "air"})
minetest.place_schematic(
{x = pos.x - ofx, y = pos.y - ofy, z = pos.z - ofz},
schem, 0, replace, false)
end
-- Register Saplings
local register_sapling = function(name, desc, texture, height)
minetest.register_node(name .. "_sapling", {
description = desc .. " Tree Sapling",
drawtype = "plantlike",
tiles = {texture .. ".png"},
inventory_image = texture .. ".png",
wield_image = texture .. ".png",
paramtype = "light",
sunlight_propagates = true,
is_ground_content = false,
walkable = false,
selection_box = {
type = "fixed",
fixed = {-4 / 16, -0.5, -4 / 16, 4 / 16, 7 / 16, 4 / 16}
},
groups = {
snappy = 2, dig_immediate = 3, flammable = 2,
epic_trees_sapling = 1, attached_node = 1, sapling = 1
},
sounds = default.node_sound_leaves_defaults(),
grown_height = height,
})
end
register_sapling("epic_trees:banana_tree", "Banana", "banana_tree_sapling", 8)
register_sapling("epic_trees:orange_tree", "Orange", "orange_tree_sapling", 6)
function epic_trees.grow_banana_tree(pos)
add_tree(pos, 3, 0, 3, epic_trees.bananatree)
end
function epic_trees.grow_orange_tree(pos)
add_tree(pos, 1, 0, 1, epic_trees.orangetree)
end
local enough_height = function(pos, height)
local nod = minetest.line_of_sight(
{x = pos.x, y = pos.y + 1, z = pos.z},
{x = pos.x, y = pos.y + height, z = pos.z})
if not nod then
return false -- obstructed
else
return true -- can grow
end
end
local function contains(table, val)
for i=1,#table do
if table[i] == val then
return true
end
end
return false
end
local grow_sapling = function(pos, node)
print("we grow")
local under = minetest.get_node({
x = pos.x,
y = pos.y - 1,
z = pos.z
}).name
if not minetest.registered_nodes[node.name] then
return
end
local height = minetest.registered_nodes[node.name].grown_height
-- do we have enough height to grow sapling into tree?
if not height or not enough_height(pos, height) then
return
end
-- Check if Ethereal Sapling is growing on correct substrate
if node.name == "epic_trees:banana_tree_sapling"
and contains({"default:dirt", "default:sand", 'default:dirt_with_grass'}, under) then
epic_trees.grow_banana_tree(pos)
end
end
minetest.register_abm({
label = "Epic Trees grow sapling",
nodenames = {"group:epic_trees_sapling"},
interval = 10,
chance = 50,
catch_up = false,
action = function(pos, node)
local light_level = minetest.get_node_light(pos) or 0
if light_level < 13 then
return
end
grow_sapling(pos, node)
end,
})

View File

@ -0,0 +1,83 @@
local _ = {name = "air", param1 = 0}
local T = {name = "epic_trees:banana_trunk", param1 = 255}
local L = {name = "epic_trees:bananaleaves", param1 = 255}
local l = {name = "epic_trees:bananaleaves", param1 = 180}
local B = {name = "epic_trees:banana", param1 = 255}
local b = {name = "epic_trees:banana", param1 = 070}
epic_trees.bananatree = {
size = {x = 7, y = 8, z = 7},
yslice_prob = {
{ypos = 0, prob = 127},
},
data = {
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,l,_,_,_,
_,_,_,L,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,b,_,_,_,
_,_,_,B,_,_,_,
_,_,_,L,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,b,T,b,_,_,
_,_,B,L,B,_,_,
_,L,L,L,L,L,_,
L,l,_,L,_,l,L,
_,_,_,T,_,_,_,
_,_,_,T,_,_,_,
_,_,_,T,_,_,_,
_,_,_,T,_,_,_,
_,_,_,b,_,_,_,
_,_,_,B,_,_,_,
_,_,_,L,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,L,_,_,_,
_,_,_,l,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,L,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
_,_,_,_,_,_,_,
}
}

View File

@ -0,0 +1,41 @@
local _ = {name = "air", param1 = 0}
local L = {name = "epic_trees:orange_leaves", param1 = 255}
local l = {name = "epic_trees:orange_leaves", param1 = 200}
local T = {name = "default:tree", param1 = 255}
local o = {name = "epic_trees:orange", param1 = 200}
epic_trees.orangetree = {
size = {x = 3, y = 6, z = 3},
yslice_prob = {
{ypos = 0, prob = 127},
{ypos = 3, prob = 127},
},
data = {
_,_,_,
_,_,_,
_,_,_,
l,l,o,
L,L,L,
l,o,l,
_,T,_,
_,T,_,
_,T,_,
l,T,l,
L,T,L,
l,L,l,
_,_,_,
_,_,_,
_,_,_,
o,l,l,
L,L,L,
l,l,l,
}
}

View File

@ -0,0 +1,35 @@
local path = minetest.get_modpath("epic_trees") .. "/schematics/"
local dpath = minetest.get_modpath("default") .. "/schematics/"
dofile(path .. "banana_tree.lua")
dofile(path .. "orange_tree.lua")
local add_schem = function(place_on, fill_ratio, biomes, y_min, y_max, schematic, flags, replacements, spawn_by, num_spawn_by, rotation)
-- if not 1 then biome disabled, don't add
if flags ~= 1 then return end
minetest.register_decoration({
deco_type = "schematic",
place_on = place_on,
sidelen = 80,
fill_ratio = fill_ratio,
biomes = biomes,
y_min = y_min,
y_max = y_max,
schematic = schematic,
flags = "place_center_x, place_center_z",
replacements = replacements,
spawn_by = spawn_by,
num_spawn_by = num_spawn_by,
rotation = rotation,
})
end
add_schem({"default:sand", "default:dirt_with_grass"}, 0.015, {"grassland", "grassland_dunes"}, 1, 100,
epic_trees.bananatree, 1)
add_schem({"default:sand", "default:dirt_with_grass"}, 0.015, {"grassland", "grassland_dunes"}, 1, 100,
epic_trees.orangetree, 1)

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 444 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 622 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 B

30
mods/epic_trees/wood.lua Normal file
View File

@ -0,0 +1,30 @@
-- banana trunk
minetest.register_node("epic_trees:banana_trunk", {
description = "Banana Trunk",
tiles = {
"banana_trunk_top.png",
"banana_trunk_top.png",
"banana_trunk.png"
},
groups = {tree = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 2},
sounds = default.node_sound_wood_defaults(),
paramtype2 = "facedir",
on_place = minetest.rotate_node,
})
-- banana wood
minetest.register_node("epic_trees:banana_wood", {
description = "Banana Wood",
tiles = {"banana_wood.png"},
is_ground_content = false,
groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, flammable = 3},
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "epic_trees:banana_wood 4",
recipe = {{"epic_trees:banana_trunk"}}
})