Add bamboo block & more crafting recipes

master
Starbeamrainbowlabs 2020-05-29 00:49:58 +01:00
parent 25afcd1c32
commit c3a28b63fa
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
6 changed files with 167 additions and 98 deletions

20
bamboo_block.lua Normal file
View File

@ -0,0 +1,20 @@
minetest.register_node("bamboo:bamboo_block", {
description = "Bamboo Block",
is_ground_content = false,
paramtype = "light",
paramtype2 = "facedir",
tiles = { "bamboo_block-dry.png" },
groups = {
flammable = 3,
float = 3,
wood = 1,
choppy = 3,
oddly_breakable_by_hand = 2
}
})
if minetest.get_modpath("default") then
minetest.override_item("bamboo:bamboo_block", {
sounds = default.node_sound_wood_defaults()
})
end

92
bamboo_plant.lua Normal file
View File

@ -0,0 +1,92 @@
minetest.register_node("bamboo:bamboo", {
description = "Bamboo",
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {
snappy = 2,
flammable = 3,
float = 3,
-- flora = 1,
attached_node = 1,
plant = 1
},
-- TODO: Make it drop an item too, but unsure how to achieve that
floodable = true,
tiles = {
"bamboo_bamboo-top.png", -- top
"bamboo_bamboo-top.png", -- bottom
"bamboo_bamboo-side.png",-- left
"bamboo_bamboo-side.png",-- right
"bamboo_bamboo-side.png",-- front
"bamboo_bamboo-side.png"-- back
},
node_box = {
type = "fixed",
fixed = {
{-0.2500, -0.5000, -0.2500, 0.2500, 0.5000, 0.2500}
}
},
on_construct = function(pos)
local pos_below = { x = pos.x, y = pos.y - 1, z = pos.z }
local node_below = minetest.get_node(pos_below)
local is_sand = minetest.get_item_group(node_below.name, "sand") ~= 0
local is_soil = minetest.get_item_group(node_below.name, "soil")
local is_growable = true
-- Apparently bamboo doesn't like wet soils
-- Ref https://dev.minetest.net/Groups/Shared_groups, if soil == 3 then it's wet
if is_soil > 2 or is_soil == 0 then is_soil = false end
-- Ref https://dev.minetest.net/Groups/Custom_groups
if minetest.get_item_group(node_below.name, "wet") > 3 then
is_growable = false
end
if minetest.get_item_group(minetest.get_node({ x = pos.x - 1, y = pos.y, z = pos.z }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x + 1, y = pos.y, z = pos.z }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y, z = pos.z - 1 }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y, z = pos.z + 1 }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }).name, "water") ~= 0
then is_growable = false end
-- Bamboo doesn't grow in the dark, as far as I know
if minetest.get_node_light(pos, 0.5) < 8 then
is_growable = false
end
if not is_sand and not is_soil then
is_growable = false
end
-- If we're not in a suitable location, then uproot
if not is_growable then
minetest.dig_node(pos)
return
end
-- Randomly set param2 to vary the eventual height it grows to, but only if it hasn't been set already
local node = minetest.get_node(pos)
if node.param2 == 0 then
node.param2 = math.random(0, 21)
minetest.set_node(pos, node)
end
end
})
minetest.register_abm({
label = "bamboo_growth",
nodenames = { "bamboo:bamboo" },
neighbours = { "air" },
interval = 45,
chance = 4, -- 1 in 2
catch_up = false,
action = function (pos, node, active_object_count, active_object_count_wider)
local pos_new = { x = pos.x, y = pos.y + 1, z = pos.z }
local node_next = minetest.get_node(pos_new)
if node_next.name ~= "air" or node.param2 > 24 then
return
end
minetest.set_node(pos_new, { name = "bamboo:bamboo", param2 = node.param2 + 1 })
end
})

42
crafting.lua Normal file
View File

@ -0,0 +1,42 @@
-- ██████ ██████ █████ ███████ ████████ ██ ███ ██ ██████
-- ██ ██ ██ ██ ██ ██ ██ ██ ████ ██ ██
-- ██ ██████ ███████ █████ ██ ██ ██ ██ ██ ██ ███
-- ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██
-- ██████ ██ ██ ██ ██ ██ ██ ██ ██ ████ ██████
minetest.register_craft({
output = "bamboo:bamboo_block",
recipe = {
{ "bamboo:bamboo", "bamboo:bamboo", "bamboo:bamboo" },
{ "bamboo:bamboo", "bamboo:bamboo", "bamboo:bamboo" },
{ "bamboo:bamboo", "bamboo:bamboo", "bamboo:bamboo" }
}
})
minetest.register_craft({
type = "shapeless",
output = "bamboo:bamboo 18",
recipe = {
"bamboo:bamboo_block",
"bamboo:bamboo_block"
}
})
-- ███████ ██ ██ ███████ ██
-- ██ ██ ██ ██ ██
-- █████ ██ ██ █████ ██
-- ██ ██ ██ ██ ██
-- ██ ██████ ███████ ███████
minetest.register_craft({
type = "fuel",
recipe = "bamboo:bamboo",
burntime = 1
})
minetest.register_craft({
type = "fuel",
recipe = "bamboo:bamboo_block",
burntime = 12 -- +3 burntime for crafting, so ~1.333 burntime / bamboo
})

View File

@ -0,0 +1 @@
default?

110
init.lua
View File

@ -1,100 +1,14 @@
--- Bamboo
-- @module bamboo
-- @release 0.1
-- @copyright 2018 Starbeamrainbowlabs
-- @license Mozilla Public License, 2.0
-- @author Starbeamrainbowlabs
bamboo = {
modpath = minetest.get_modpath("bamboo")
}
minetest.register_node("bamboo:bamboo", {
description = "Bamboo",
drawtype = "nodebox",
paramtype = "light",
is_ground_content = false,
groups = {
snappy = 2,
flammable = 3,
float = 3,
-- flora = 1,
attached_node = 1,
plant = 1
},
-- TODO: Make it drop an item too, but unsure how to achieve that
floodable = true,
tiles = {
"bamboo_bamboo-top.png", -- top
"bamboo_bamboo-top.png", -- bottom
"bamboo_bamboo-side.png",-- left
"bamboo_bamboo-side.png",-- right
"bamboo_bamboo-side.png",-- front
"bamboo_bamboo-side.png"-- back
},
node_box = {
type = "fixed",
fixed = {
{-0.2500, -0.5000, -0.2500, 0.2500, 0.5000, 0.2500}
}
},
on_construct = function(pos)
local pos_below = { x = pos.x, y = pos.y - 1, z = pos.z }
local node_below = minetest.get_node(pos_below)
local is_sand = minetest.get_item_group(node_below.name, "sand") ~= 0
local is_soil = minetest.get_item_group(node_below.name, "soil")
local is_growable = true
-- Apparently bamboo doesn't like wet soils
-- Ref https://dev.minetest.net/Groups/Shared_groups, if soil == 3 then it's wet
if is_soil > 2 or is_soil == 0 then is_soil = false end
-- Ref https://dev.minetest.net/Groups/Custom_groups
if minetest.get_item_group(node_below.name, "wet") > 3 then
is_growable = false
end
if minetest.get_item_group(minetest.get_node({ x = pos.x - 1, y = pos.y, z = pos.z }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x + 1, y = pos.y, z = pos.z }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y, z = pos.z - 1 }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y, z = pos.z + 1 }).name, "water") ~= 0
or minetest.get_item_group(minetest.get_node({ x = pos.x, y = pos.y + 1, z = pos.z }).name, "water") ~= 0
then is_growable = false end
-- Bamboo doesn't grow in the dark, as far as I know
if minetest.get_node_light(pos, 0.5) < 8 then
is_growable = false
end
if not is_sand and not is_soil then
is_growable = false
end
-- If we're not in a suitable location, then uproot
if not is_growable then
minetest.dig_node(pos)
return
end
-- Randomly set param2 to vary the eventual height it grows to, but only if it hasn't been set already
local node = minetest.get_node(pos)
if node.param2 == 0 then
node.param2 = math.random(0, 21)
minetest.set_node(pos, node)
end
end
})
minetest.register_abm({
label = "bamboo_growth",
nodenames = { "bamboo:bamboo" },
neighbours = { "air" },
interval = 45,
chance = 4, -- 1 in 2
catch_up = false,
action = function (pos, node, active_object_count, active_object_count_wider)
local pos_new = { x = pos.x, y = pos.y + 1, z = pos.z }
local node_next = minetest.get_node(pos_new)
if node_next.name ~= "air" or node.param2 > 24 then
return
end
minetest.set_node(pos_new, { name = "bamboo:bamboo", param2 = node.param2 + 1 })
end
})
minetest.register_craft({
type = "fuel",
recipe = "bamboo:bamboo",
burntime = 1
})
dofile(bamboo.modpath.."/bamboo_plant.lua");
dofile(bamboo.modpath.."/bamboo_block.lua");
dofile(bamboo.modpath.."/crafting.lua");

Binary file not shown.

After

Width:  |  Height:  |  Size: 419 B