2021-05-29 14:12:33 +00:00
local modname = minetest.get_current_modname ( )
local modpath = minetest.get_modpath ( modname )
local S = minetest.get_translator ( modname )
local mod_screwdriver = minetest.get_modpath ( " screwdriver " )
2021-03-11 21:13:43 +00:00
local has_mcl_flowerpots = minetest.get_modpath ( " mcl_flowerpots " )
2019-12-14 21:13:54 +00:00
2021-03-11 17:31:29 +00:00
mcl_flowers = { }
2021-03-11 17:49:16 +00:00
mcl_flowers.registered_simple_flowers = { }
2017-03-14 16:07:07 +00:00
-- Simple flower template
2019-03-07 23:22:28 +00:00
local smallflowerlongdesc = S ( " This is a small flower. Small flowers are mainly used for dye production and can also be potted. " )
local plant_usage_help = S ( " It can only be placed on a block on which it would also survive. " )
2015-06-29 17:55:56 +00:00
2019-12-14 00:15:37 +00:00
local get_palette_color_from_pos = function ( pos )
local biome_data = minetest.get_biome_data ( pos )
local index = 0
if biome_data then
local biome = biome_data.biome
local biome_name = minetest.get_biome_name ( biome )
local reg_biome = minetest.registered_biomes [ biome_name ]
if reg_biome then
2022-12-28 19:32:42 +00:00
index = reg_biome._mcl_grass_palette_index
2019-12-14 00:15:37 +00:00
end
end
return index
end
2017-06-09 18:20:29 +00:00
-- on_place function for flowers
2017-11-15 00:29:17 +00:00
local on_place_flower = mcl_util.generate_on_place_plant_function ( function ( pos , node , itemstack )
2017-06-09 18:20:29 +00:00
local below = { x = pos.x , y = pos.y - 1 , z = pos.z }
local soil_node = minetest.get_node_or_nil ( below )
2017-06-09 18:39:46 +00:00
if not soil_node then return false end
2017-06-09 18:20:29 +00:00
2017-11-16 02:13:19 +00:00
local has_palette = minetest.registered_nodes [ itemstack : get_name ( ) ] . palette ~= nil
2017-11-16 06:48:55 +00:00
local colorize
if has_palette then
2019-12-14 00:15:37 +00:00
colorize = get_palette_color_from_pos ( pos )
2017-11-16 06:48:55 +00:00
end
if not colorize then
colorize = 0
2017-11-15 00:29:17 +00:00
end
2017-06-09 18:20:29 +00:00
--[[ Placement requirements:
* Dirt or grass block
2017-11-15 04:02:37 +00:00
* If not flower , also allowed on podzol and coarse dirt
2017-06-09 18:20:29 +00:00
* Light level >= 8 at any time or exposed to sunlight at day
] ]
local light_night = minetest.get_node_light ( pos , 0.0 )
local light_day = minetest.get_node_light ( pos , 0.5 )
local light_ok = false
if ( light_night and light_night >= 8 ) or ( light_day and light_day >= minetest.LIGHT_MAX ) then
light_ok = true
end
2022-10-28 19:02:45 +00:00
if itemstack : get_name ( ) == " mcl_flowers:wither_rose " and ( minetest.get_item_group ( soil_node.name , " grass_block " ) > 0 or soil_node.name == " mcl_core:dirt " or soil_node.name == " mcl_core:coarse_dirt " or soil_node.name == " mcl_mud:mud " or soil_node.name == " mcl_moss:moss " or soil_node.name == " mcl_nether:netherrack " or minetest.get_item_group ( soil_node.name , " soul_block " ) > 0 ) then
return true , colorize
end
2017-11-15 04:02:37 +00:00
local is_flower = minetest.get_item_group ( itemstack : get_name ( ) , " flower " ) == 1
local ok = ( soil_node.name == " mcl_core:dirt " or minetest.get_item_group ( soil_node.name , " grass_block " ) == 1 or ( not is_flower and ( soil_node.name == " mcl_core:coarse_dirt " or soil_node.name == " mcl_core:podzol " or soil_node.name == " mcl_core:podzol_snow " ) ) ) and light_ok
2017-11-16 02:13:19 +00:00
return ok , colorize
2017-06-09 18:20:29 +00:00
end )
2021-03-11 21:13:43 +00:00
function mcl_flowers . register_simple_flower ( name , def )
2021-03-11 17:49:16 +00:00
local newname = " mcl_flowers: " .. name
2021-03-11 21:13:43 +00:00
if not def._mcl_silk_touch_drop then def._mcl_silk_touch_drop = nil end
if not def.drop then def.drop = newname end
2021-05-29 14:12:33 +00:00
mcl_flowers.registered_simple_flowers [ newname ] = {
2021-03-11 21:13:43 +00:00
name = name ,
2021-03-12 09:03:57 +00:00
desc = def.desc ,
image = def.image ,
simple_selection_box = def.simple_selection_box ,
2021-03-11 17:49:16 +00:00
}
minetest.register_node ( newname , {
2021-03-11 21:13:43 +00:00
description = def.desc ,
2017-03-11 00:51:06 +00:00
_doc_items_longdesc = smallflowerlongdesc ,
2017-11-15 04:02:37 +00:00
_doc_items_usagehelp = plant_usage_help ,
2015-06-29 17:55:56 +00:00
drawtype = " plantlike " ,
2017-09-13 04:50:54 +00:00
waving = 1 ,
2021-03-11 21:13:43 +00:00
tiles = { def.image } ,
inventory_image = def.image ,
wield_image = def.image ,
2015-06-29 17:55:56 +00:00
sunlight_propagates = true ,
paramtype = " light " ,
walkable = false ,
stack_max = 64 ,
2021-03-11 21:13:43 +00:00
drop = def.drop ,
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
groups = {
attached_node = 1 , deco_block = 1 , dig_by_piston = 1 , dig_immediate = 3 ,
dig_by_water = 1 , destroy_by_lava_flow = 1 , enderman_takable = 1 ,
plant = 1 , flower = 1 , place_flowerlike = 1 , non_mycelium_plant = 1 ,
flammable = 2 , fire_encouragement = 60 , fire_flammability = 100 ,
compostability = 65
} ,
2017-02-11 17:46:23 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
2017-05-13 23:45:57 +00:00
node_placement_prediction = " " ,
2017-06-09 18:20:29 +00:00
on_place = on_place_flower ,
2015-06-29 17:55:56 +00:00
selection_box = {
type = " fixed " ,
2021-03-11 21:13:43 +00:00
fixed = def.selection_box ,
2015-06-29 17:55:56 +00:00
} ,
2021-03-11 21:13:43 +00:00
_mcl_silk_touch_drop = def._mcl_silk_touch_drop ,
2015-06-29 17:55:56 +00:00
} )
2021-03-11 21:13:43 +00:00
if def.potted and has_mcl_flowerpots then
mcl_flowerpots.register_potted_flower ( newname , {
name = name ,
desc = def.desc ,
image = def.image ,
} )
end
2015-06-29 17:55:56 +00:00
end
2017-03-14 18:26:48 +00:00
local wheat_seed_drop = {
max_items = 1 ,
items = {
{
2021-05-29 14:12:33 +00:00
items = { " mcl_farming:wheat_seeds " } ,
2017-03-14 18:26:48 +00:00
rarity = 8 ,
} ,
2021-05-29 14:12:33 +00:00
} ,
2017-03-14 23:03:02 +00:00
}
2017-03-14 18:26:48 +00:00
2020-11-06 12:46:52 +00:00
local fortune_wheat_seed_drop = {
discrete_uniform_distribution = true ,
items = { " mcl_farming:wheat_seeds " } ,
chance = 1 / 8 ,
min_count = 1 ,
max_count = 1 ,
factor = 2 ,
overwrite = true ,
}
2017-11-16 02:13:19 +00:00
--- Tall Grass ---
local def_tallgrass = {
2019-03-07 23:22:28 +00:00
description = S ( " Tall Grass " ) ,
2017-11-16 02:13:19 +00:00
drawtype = " plantlike " ,
2019-03-15 05:12:03 +00:00
_doc_items_longdesc = S ( " Tall grass is a small plant which often occurs on the surface of grasslands. It can be harvested for wheat seeds. By using bone meal, tall grass can be turned into double tallgrass which is two blocks high. " ) ,
2017-11-16 02:13:19 +00:00
_doc_items_usagehelp = plant_usage_help ,
_doc_items_hidden = false ,
waving = 1 ,
tiles = { " mcl_flowers_tallgrass.png " } ,
inventory_image = " mcl_flowers_tallgrass_inv.png " ,
wield_image = " mcl_flowers_tallgrass_inv.png " ,
selection_box = {
type = " fixed " ,
fixed = { { - 6 / 16 , - 8 / 16 , - 6 / 16 , 6 / 16 , 4 / 16 , 6 / 16 } } ,
} ,
paramtype = " light " ,
paramtype2 = " color " ,
palette = " mcl_core_palette_grass.png " ,
sunlight_propagates = true ,
walkable = false ,
buildable_to = true ,
is_ground_content = true ,
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
groups = {
handy = 1 , shearsy = 1 , attached_node = 1 , deco_block = 1 ,
plant = 1 , place_flowerlike = 2 , non_mycelium_plant = 1 ,
2023-07-06 13:34:49 +00:00
flammable = 3 , fire_encouragement = 60 , fire_flammability = 10 , dig_by_piston = 1 ,
2023-02-24 13:55:48 +00:00
dig_by_water = 1 , destroy_by_lava_flow = 1 , compostability = 30 , grass_palette = 1
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
} ,
2017-11-16 02:13:19 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
drop = wheat_seed_drop ,
_mcl_shears_drop = true ,
2020-11-06 12:46:52 +00:00
_mcl_fortune_drop = fortune_wheat_seed_drop ,
2017-11-16 02:13:19 +00:00
node_placement_prediction = " " ,
on_place = on_place_flower ,
_mcl_blast_resistance = 0 ,
_mcl_hardness = 0 ,
}
minetest.register_node ( " mcl_flowers:tallgrass " , def_tallgrass )
2017-11-14 22:44:53 +00:00
2017-11-16 02:13:19 +00:00
--- Fern ---
-- The fern is very similar to tall grass, so we can copy a lot from it.
local def_fern = table.copy ( def_tallgrass )
2019-03-07 23:22:28 +00:00
def_fern.description = S ( " Fern " )
2019-03-15 05:12:03 +00:00
def_fern._doc_items_longdesc = S ( " Ferns are small plants which occur naturally in jungles and taigas. They can be harvested for wheat seeds. By using bone meal, a fern can be turned into a large fern which is two blocks high. " )
2017-11-16 02:13:19 +00:00
def_fern.tiles = { " mcl_flowers_fern.png " }
def_fern.inventory_image = " mcl_flowers_fern_inv.png "
def_fern.wield_image = " mcl_flowers_fern_inv.png "
def_fern.selection_box = {
type = " fixed " ,
fixed = { - 6 / 16 , - 0.5 , - 6 / 16 , 6 / 16 , 5 / 16 , 6 / 16 } ,
}
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
def_fern.groups . compostability = 65
2017-11-14 22:44:53 +00:00
2017-11-16 02:13:19 +00:00
minetest.register_node ( " mcl_flowers:fern " , def_fern )
2015-06-29 17:55:56 +00:00
2024-03-20 21:18:47 +00:00
--- Clover ---
-- Similar deal as fern, we can copy a lot from tall grass
local def_clover = table.copy ( def_tallgrass )
def_clover.description = S ( " Clover " )
def_clover._doc_items_longdesc = S ( " Clovers are small plants which occur naturally in plains and other temperate biomes. They can be picked up and planted again. " )
def_clover.drawtype = " mesh "
def_clover.mesh = " mcl_clover_3leaf.obj "
def_clover.tiles = { " mcl_flowers_clover.png " }
def_clover.inventory_image = " mcl_flowers_clover_inv.png "
def_clover.wield_image = " mcl_flowers_clover_inv.png "
def_clover.drop = nil
def_clover.selection_box = {
type = " fixed " ,
fixed = { - 4 / 16 , - 0.5 , - 4 / 16 , 4 / 16 , 0 , 4 / 16 } ,
}
def_clover.groups . compostability = 30
minetest.register_node ( " mcl_flowers:clover " , def_clover )
local def_4l_clover = table.copy ( def_clover )
def_4l_clover.description = S ( " Four-leaf Clover " )
def_4l_clover._doc_items_longdesc = S ( " Clovers are small plants which occur naturally in plains and other temperate biomes. They can be picked up and planted again. " )
def_4l_clover.mesh = " mcl_clover_4leaf.obj "
def_4l_clover.tiles = { " mcl_flowers_fourleaf_clover.png " }
def_4l_clover.inventory_image = " mcl_flowers_fourleaf_clover_inv.png "
def_4l_clover.wield_image = " mcl_flowers_fourleaf_clover_inv.png "
minetest.register_node ( " mcl_flowers:fourleaf_clover " , def_4l_clover )
2021-03-11 21:42:42 +00:00
if has_mcl_flowerpots then
mcl_flowerpots.register_potted_flower ( " mcl_flowers:fern " , {
name = " fern " ,
desc = S ( " Fern " ) ,
2021-03-11 23:47:34 +00:00
image = " mcl_flowers_fern_inv.png " ,
2023-02-24 13:55:48 +00:00
grass_palette_group = 1
2021-03-11 21:42:42 +00:00
} )
end
2023-12-15 11:54:44 +00:00
local function add_large_plant ( name , desc , longdesc , bottom_img , top_img , inv_img , selbox_radius , selbox_top_height , drop , shears_drop , is_flower , grass_color , fortune_drop , mesh )
2017-03-14 17:53:31 +00:00
if not inv_img then
inv_img = top_img
end
2021-05-22 21:29:51 +00:00
local create_entry , paramtype2 , palette
2017-05-13 23:50:00 +00:00
if is_flower == nil then
is_flower = true
end
2017-11-20 08:35:08 +00:00
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
local bottom_groups = {
attached_node = 1 , deco_block = 1 ,
dig_by_water = 1 , destroy_by_lava_flow = 1 , dig_by_piston = 1 ,
flammable = 2 , fire_encouragement = 60 , fire_flammability = 100 ,
2023-02-24 13:55:48 +00:00
plant = 1 , double_plant = 1 , non_mycelium_plant = 1 , compostability = 65 , grass_palette = nil
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
}
if name == " double_grass " then
bottom_groups.compostability = 50
end
2017-05-13 23:50:00 +00:00
if is_flower then
2017-11-20 08:35:08 +00:00
bottom_groups.flower = 1
bottom_groups.place_flowerlike = 1
bottom_groups.dig_immediate = 3
2017-11-15 04:02:37 +00:00
else
2017-11-20 08:35:08 +00:00
bottom_groups.place_flowerlike = 2
bottom_groups.handy = 1
bottom_groups.shearsy = 1
2017-05-13 23:50:00 +00:00
end
2017-11-16 02:13:19 +00:00
if grass_color then
paramtype2 = " color "
palette = " mcl_core_palette_grass.png "
2023-02-24 13:55:48 +00:00
bottom_groups.grass_palette = 1
2017-11-16 02:13:19 +00:00
end
2017-11-14 22:44:53 +00:00
if longdesc == nil then
2021-05-22 21:29:51 +00:00
bottom_groups.not_in_creative_inventory = 1
2017-11-14 22:44:53 +00:00
create_entry = false
end
2017-08-03 02:03:56 +00:00
-- Drop itself by default
local drop_bottom , drop_top
2017-08-03 02:00:01 +00:00
if not drop then
2017-08-03 02:03:56 +00:00
drop_top = " mcl_flowers: " .. name
else
drop_top = drop
drop_bottom = drop
2017-08-03 02:00:01 +00:00
end
2023-12-15 11:54:44 +00:00
-- Sunflower mesh and tiles
local top_drawtype , bottom_drawtype
local bottom_tiles = { }
if not mesh then
top_drawtype = " plantlike "
bottom_drawtype = " plantlike "
table.insert ( bottom_tiles , bottom_img )
else
top_drawtype = " airlike "
bottom_drawtype = " mesh "
bottom_tiles = bottom_img
end
-- Bottom
2017-03-14 17:45:21 +00:00
minetest.register_node ( " mcl_flowers: " .. name , {
description = desc ,
2017-11-14 22:44:53 +00:00
_doc_items_create_entry = create_entry ,
2017-03-14 17:45:21 +00:00
_doc_items_longdesc = longdesc ,
2017-11-15 04:02:37 +00:00
_doc_items_usagehelp = plant_usage_help ,
2023-12-15 11:54:44 +00:00
drawtype = bottom_drawtype ,
tiles = bottom_tiles ,
2017-03-14 17:45:21 +00:00
inventory_image = inv_img ,
wield_image = inv_img ,
sunlight_propagates = true ,
paramtype = " light " ,
2017-11-16 02:13:19 +00:00
paramtype2 = paramtype2 ,
palette = palette ,
2017-03-14 17:45:21 +00:00
walkable = false ,
2023-07-02 12:30:36 +00:00
buildable_to = false ,
2017-08-03 02:03:56 +00:00
drop = drop_bottom ,
2017-08-03 01:12:06 +00:00
_mcl_shears_drop = shears_drop ,
2020-11-06 12:46:52 +00:00
_mcl_fortune_drop = fortune_drop ,
2017-03-14 17:45:21 +00:00
node_placement_prediction = " " ,
2017-06-06 11:07:46 +00:00
selection_box = {
type = " fixed " ,
fixed = { - selbox_radius , - 0.5 , - selbox_radius , selbox_radius , 0.5 , selbox_radius } ,
} ,
2017-03-14 17:45:21 +00:00
on_place = function ( itemstack , placer , pointed_thing )
-- We can only place on nodes
if pointed_thing.type ~= " node " then
2017-11-15 00:29:17 +00:00
return
2017-03-14 17:45:21 +00:00
end
2017-03-29 21:42:28 +00:00
2017-11-15 00:29:17 +00:00
local itemstring = " mcl_flowers: " .. name
2017-03-29 21:42:28 +00:00
-- Call on_rightclick if the pointed node defines it
local node = minetest.get_node ( pointed_thing.under )
if placer and not placer : get_player_control ( ) . sneak then
if minetest.registered_nodes [ node.name ] and minetest.registered_nodes [ node.name ] . on_rightclick then
return minetest.registered_nodes [ node.name ] . on_rightclick ( pointed_thing.under , node , placer , itemstack ) or itemstack
end
end
2017-03-14 17:45:21 +00:00
-- Check for a floor and a space of 1× 2× 1
local ptu_node = minetest.get_node ( pointed_thing.under )
local bottom
2017-06-29 11:02:53 +00:00
if not minetest.registered_nodes [ ptu_node.name ] then
return itemstack
end
2017-03-14 17:45:21 +00:00
if minetest.registered_nodes [ ptu_node.name ] . buildable_to then
bottom = pointed_thing.under
else
bottom = pointed_thing.above
end
2017-06-29 11:02:53 +00:00
if not minetest.registered_nodes [ minetest.get_node ( bottom ) . name ] then
return itemstack
end
2017-03-14 17:45:21 +00:00
local top = { x = bottom.x , y = bottom.y + 1 , z = bottom.z }
local bottom_buildable = minetest.registered_nodes [ minetest.get_node ( bottom ) . name ] . buildable_to
local top_buildable = minetest.registered_nodes [ minetest.get_node ( top ) . name ] . buildable_to
2019-12-13 13:28:24 +00:00
local floor = minetest.get_node ( { x = bottom.x , y = bottom.y - 1 , z = bottom.z } )
if not minetest.registered_nodes [ floor.name ] then
2017-06-29 11:02:53 +00:00
return itemstack
end
2017-06-09 17:41:23 +00:00
local light_night = minetest.get_node_light ( bottom , 0.0 )
local light_day = minetest.get_node_light ( bottom , 0.5 )
local light_ok = false
if ( light_night and light_night >= 8 ) or ( light_day and light_day >= minetest.LIGHT_MAX ) then
light_ok = true
end
-- Placement rules:
-- * Allowed on dirt or grass block
2017-11-15 04:02:37 +00:00
-- * If not a flower, also allowed on podzol and coarse dirt
2017-06-09 17:41:23 +00:00
-- * Only with light level >= 8
-- * Only if two enough space
2019-12-13 13:28:24 +00:00
if ( floor.name == " mcl_core:dirt " or minetest.get_item_group ( floor.name , " grass_block " ) == 1 or ( not is_flower and ( floor.name == " mcl_core:coarse_dirt " or floor.name == " mcl_core:podzol " or floor.name == " mcl_core:podzol_snow " ) ) ) and bottom_buildable and top_buildable and light_ok then
2017-11-16 02:13:19 +00:00
local param2
2017-11-16 06:48:55 +00:00
if grass_color then
2019-12-14 00:15:37 +00:00
param2 = get_palette_color_from_pos ( bottom )
2017-11-15 00:29:17 +00:00
end
2017-03-14 17:45:21 +00:00
-- Success! We can now place the flower
2020-04-06 22:55:45 +00:00
minetest.sound_play ( minetest.registered_nodes [ itemstring ] . sounds.place , { pos = bottom , gain = 1 } , true )
2017-11-16 02:13:19 +00:00
minetest.set_node ( bottom , { name = itemstring , param2 = param2 } )
minetest.set_node ( top , { name = itemstring .. " _top " , param2 = param2 } )
2020-07-10 14:08:40 +00:00
if not minetest.is_creative_enabled ( placer : get_player_name ( ) ) then
2017-03-14 17:45:21 +00:00
itemstack : take_item ( )
end
end
return itemstack
end ,
after_destruct = function ( pos , oldnode )
-- Remove top half of flower (if it exists)
local bottom = pos
local top = { x = bottom.x , y = bottom.y + 1 , z = bottom.z }
2017-03-31 18:25:16 +00:00
if minetest.get_node ( bottom ) . name ~= " mcl_flowers: " .. name and minetest.get_node ( top ) . name == " mcl_flowers: " .. name .. " _top " then
2017-03-14 17:45:21 +00:00
minetest.remove_node ( top )
end
end ,
2017-11-20 08:35:08 +00:00
groups = bottom_groups ,
2017-03-14 17:45:21 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
2023-12-15 11:54:44 +00:00
mesh = mesh
2017-03-14 17:45:21 +00:00
} )
2015-06-29 17:55:56 +00:00
2017-11-20 08:35:08 +00:00
local top_groups = table.copy ( bottom_groups )
top_groups.not_in_creative_inventory = 1
top_groups.double_plant = 2
top_groups.attached_node = nil
2017-03-14 17:45:21 +00:00
-- Top
minetest.register_node ( " mcl_flowers: " .. name .. " _top " , {
2019-03-07 23:22:28 +00:00
description = desc .. " " .. S ( " (Top Part) " ) ,
2017-03-14 17:45:21 +00:00
_doc_items_create_entry = false ,
2023-12-15 11:54:44 +00:00
drawtype = top_drawtype ,
2017-03-14 17:45:21 +00:00
tiles = { top_img } ,
sunlight_propagates = true ,
paramtype = " light " ,
2017-11-16 02:13:19 +00:00
paramtype2 = paramtype2 ,
palette = palette ,
2017-03-14 17:45:21 +00:00
walkable = false ,
2023-07-02 12:30:36 +00:00
buildable_to = false ,
2017-06-06 11:07:46 +00:00
selection_box = {
type = " fixed " ,
fixed = { - selbox_radius , - 0.5 , - selbox_radius , selbox_radius , selbox_top_height , selbox_radius } ,
} ,
2017-08-03 02:03:56 +00:00
drop = drop_top ,
2017-08-03 01:12:06 +00:00
_mcl_shears_drop = shears_drop ,
2020-11-06 12:46:52 +00:00
_mcl_fortune_drop = fortune_drop ,
2017-03-14 17:45:21 +00:00
after_destruct = function ( pos , oldnode )
2017-08-03 01:12:06 +00:00
-- Remove bottom half of flower (if it exists)
2017-03-14 17:45:21 +00:00
local top = pos
local bottom = { x = top.x , y = top.y - 1 , z = top.z }
2017-03-31 18:25:16 +00:00
if minetest.get_node ( top ) . name ~= " mcl_flowers: " .. name .. " _top " and minetest.get_node ( bottom ) . name == " mcl_flowers: " .. name then
2017-08-03 01:12:06 +00:00
minetest.remove_node ( bottom )
2017-03-14 17:45:21 +00:00
end
end ,
2017-11-20 08:35:08 +00:00
groups = top_groups ,
2017-03-14 17:45:21 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
} )
2017-03-20 17:12:05 +00:00
2017-11-14 22:44:53 +00:00
if minetest.get_modpath ( " doc " ) and longdesc then
2017-03-20 17:12:05 +00:00
doc.add_entry_alias ( " nodes " , " mcl_flowers: " .. name , " nodes " , " mcl_flowers: " .. name .. " _top " )
2017-11-14 22:44:53 +00:00
-- If no longdesc, help alias must be added manually
2017-03-20 17:12:05 +00:00
end
2015-06-29 17:55:56 +00:00
end
2020-07-11 09:53:08 +00:00
add_large_plant ( " peony " , S ( " Peony " ) , S ( " A peony is a large plant which occupies two blocks. It is mainly used in dye production. " ) , " mcl_flowers_double_plant_paeonia_bottom.png " , " mcl_flowers_double_plant_paeonia_top.png " , nil , 5 / 16 , 6 / 16 )
add_large_plant ( " rose_bush " , S ( " Rose Bush " ) , S ( " A rose bush is a large plant which occupies two blocks. It is safe to touch it. Rose bushes are mainly used in dye production. " ) , " mcl_flowers_double_plant_rose_bottom.png " , " mcl_flowers_double_plant_rose_top.png " , nil , 5 / 16 , 1 / 16 )
2019-03-07 23:22:28 +00:00
add_large_plant ( " lilac " , S ( " Lilac " ) , S ( " A lilac is a large plant which occupies two blocks. It is mainly used in dye production. " ) , " mcl_flowers_double_plant_syringa_bottom.png " , " mcl_flowers_double_plant_syringa_top.png " , nil , 5 / 16 , 6 / 16 )
2023-12-15 11:54:44 +00:00
add_large_plant ( " sunflower " , S ( " Sunflower " ) , S ( " A sunflower is a large plant which occupies two blocks. It is mainly used in dye production. " ) , { " mcl_flowers_double_plant_sunflower_bottom.png " , " mcl_flowers_double_plant_sunflower_bottom.png " , " mcl_flowers_double_plant_sunflower_front.png " , " mcl_flowers_double_plant_sunflower_back.png " } , nil , " mcl_flowers_double_plant_sunflower_front.png " , 6 / 16 , 6 / 16 , " mcl_flowers:sunflower " , nil , true , nil , nil , " mcl_flowers_sunflower.obj " )
2017-03-14 18:26:48 +00:00
2019-03-07 23:22:28 +00:00
local longdesc_grass = S ( " Double tallgrass a variant of tall grass and occupies two blocks. It can be harvested for wheat seeds. " )
local longdesc_fern = S ( " Large fern is a variant of fern and occupies two blocks. It can be harvested for wheat seeds. " )
2017-11-14 22:44:53 +00:00
2022-04-30 21:30:58 +00:00
add_large_plant ( " double_grass " , S ( " Double Tallgrass " ) , longdesc_grass , " mcl_flowers_double_plant_grass_bottom.png " , " mcl_flowers_double_plant_grass_top.png " , " mcl_flowers_double_plant_grass_inv.png " , 6 / 16 , 4 / 16 , wheat_seed_drop , { " mcl_flowers:tallgrass 2 " } , false , true , fortune_wheat_seed_drop )
add_large_plant ( " double_fern " , S ( " Large Fern " ) , longdesc_fern , " mcl_flowers_double_plant_fern_bottom.png " , " mcl_flowers_double_plant_fern_top.png " , " mcl_flowers_double_plant_fern_inv.png " , 5 / 16 , 5 / 16 , wheat_seed_drop , { " mcl_flowers:fern 2 " } , false , true , fortune_wheat_seed_drop )
2015-06-29 17:55:56 +00:00
2017-06-09 17:59:49 +00:00
minetest.register_abm ( {
2017-06-09 18:39:46 +00:00
label = " Pop out flowers " ,
nodenames = { " group:flower " } ,
2017-06-09 17:59:49 +00:00
interval = 12 ,
chance = 2 ,
action = function ( pos , node )
2017-06-10 02:12:13 +00:00
-- Ignore the upper part of double plants
if minetest.get_item_group ( node.name , " double_plant " ) == 2 then
return
end
2017-06-09 17:59:49 +00:00
local below = minetest.get_node_or_nil ( { x = pos.x , y = pos.y - 1 , z = pos.z } )
if not below then
return
end
-- Pop out flower if not on dirt, grass block or too low brightness
2017-11-14 22:44:53 +00:00
if ( below.name ~= " mcl_core:dirt " and minetest.get_item_group ( below.name , " grass_block " ) ~= 1 ) or ( minetest.get_node_light ( pos , 0.5 ) < 8 ) then
2017-06-09 17:59:49 +00:00
minetest.dig_node ( pos )
return
end
end ,
} )
2019-12-14 21:13:54 +00:00
local on_rotate
if mod_screwdriver then
on_rotate = screwdriver.rotate_simple
end
2017-06-09 17:59:49 +00:00
2017-01-12 03:37:36 +00:00
-- Lily Pad
2017-01-31 11:03:18 +00:00
minetest.register_node ( " mcl_flowers:waterlily " , {
2019-03-07 23:22:28 +00:00
description = S ( " Lily Pad " ) ,
_doc_items_longdesc = S ( " A lily pad is a flat plant block which can be walked on. They can be placed on water sources, ice and frosted ice. " ) ,
2017-01-12 03:37:36 +00:00
drawtype = " nodebox " ,
paramtype = " light " ,
paramtype2 = " facedir " ,
2017-01-31 23:35:04 +00:00
tiles = { " flowers_waterlily.png " , " flowers_waterlily.png^[transformFY " } ,
2023-02-09 09:46:18 +00:00
color = " #208030 " ,
2021-02-18 13:00:17 +00:00
use_texture_alpha = minetest.features . use_texture_alpha_string_modes and " clip " or true ,
2017-01-12 03:37:36 +00:00
inventory_image = " flowers_waterlily.png " ,
wield_image = " flowers_waterlily.png " ,
liquids_pointable = true ,
walkable = true ,
sunlight_propagates = true ,
Add `compostability` to node definition group.
* mcl_cake/init.lua (cake);
* mcl_core/craftitems.lua (apple);
* mcl_core/nodes_base.lua (dirt with grass);
* mcl_core/nodes_cactuscane.lua (cactus, sugarcane);
* mcl_core/nodes_climb.lua (vines);
* mcl_core/nodes_trees.lua (leaves, saplings);
* mcl_dye/init.lua (cocoa beans);
* mcl_farming/beetroot.lua (beetroot, & seeds);
* mcl_farming/carrots.lua (carrot);
* mcl_farming/melon.lua (melon, & slice, & seeds);
* mcl_farming/potatoes.lua (potato, baked potato);
* mcl_farming/pumpkin.lua (pumpkin, carved &, & seeds, & pie);
* mcl_farming/wheat.lua (wheat, cookie, bread, hay block);
* mcl_flowers/init.lua (flowers, ferns, grass, & tall variants);
* mcl_mushrooms/small.lua (red and brown mushrooms);
* mcl_mushrooms/huge.lua (red and brown huge mushrooms);
* mcl_nether/init.lua (nether wart block);
* mcl_nether/nether_wart.lua (nether wart);
* mcl_ocean/kelp.lua (kelp, dried &, & block);
* mcl_ocean/sea_pickle.lua (sea pickle);
* mcl_ocean/seagrass.lua (seagrass).
2022-03-29 10:54:51 +00:00
groups = {
deco_block = 1 , plant = 1 , compostability = 65 , destroy_by_lava_flow = 1 ,
dig_immediate = 3 , dig_by_water = 1 , dig_by_piston = 1 , dig_by_boat = 1 ,
} ,
2017-02-11 17:46:23 +00:00
sounds = mcl_sounds.node_sound_leaves_defaults ( ) ,
2017-01-12 03:37:36 +00:00
node_placement_prediction = " " ,
node_box = {
type = " fixed " ,
2017-02-10 06:35:45 +00:00
fixed = { - 0.5 , - 31 / 64 , - 0.5 , 0.5 , - 15 / 32 , 0.5 }
2017-01-12 03:37:36 +00:00
} ,
selection_box = {
type = " fixed " ,
fixed = { - 7 / 16 , - 0.5 , - 7 / 16 , 7 / 16 , - 15 / 32 , 7 / 16 }
} ,
on_place = function ( itemstack , placer , pointed_thing )
local pos = pointed_thing.above
2017-03-02 15:20:19 +00:00
local node = minetest.get_node ( pointed_thing.under )
local nodename = node.name
local def = minetest.registered_nodes [ nodename ]
2017-01-12 03:37:36 +00:00
local node_above = minetest.get_node ( pointed_thing.above ) . name
local def_above = minetest.registered_nodes [ node_above ]
local player_name = placer : get_player_name ( )
2017-03-02 15:20:19 +00:00
if def then
-- Use pointed node's on_rightclick function first, if present
if placer and not placer : get_player_control ( ) . sneak then
if def and def.on_rightclick then
return def.on_rightclick ( pointed_thing.under , node , placer , itemstack ) or itemstack
end
end
if ( pointed_thing.under . x == pointed_thing.above . x and pointed_thing.under . z == pointed_thing.above . z ) and
( ( def.liquidtype == " source " and minetest.get_item_group ( nodename , " water " ) > 0 ) or
( nodename == " mcl_core:ice " ) or
( minetest.get_item_group ( nodename , " frosted_ice " ) > 0 ) ) and
2017-01-12 03:37:36 +00:00
( def_above.buildable_to and minetest.get_item_group ( node_above , " liquid " ) == 0 ) then
if not minetest.is_protected ( pos , player_name ) then
2017-07-24 19:26:49 +00:00
minetest.set_node ( pos , { name = " mcl_flowers:waterlily " , param2 = math.random ( 0 , 3 ) } )
local idef = itemstack : get_definition ( )
if idef.sounds and idef.sounds . place then
2020-04-06 22:55:45 +00:00
minetest.sound_play ( idef.sounds . place , { pos = pointed_thing.above , gain = 1 } , true )
2017-07-24 19:26:49 +00:00
end
2020-07-10 14:08:40 +00:00
if not minetest.is_creative_enabled ( player_name ) then
2017-01-12 03:37:36 +00:00
itemstack : take_item ( )
end
else
minetest.record_protection_violation ( pos , player_name )
end
end
end
return itemstack
2019-12-14 21:13:54 +00:00
end ,
on_rotate = on_rotate ,
2017-01-12 03:37:36 +00:00
} )
2017-01-05 06:23:25 +00:00
2017-03-14 19:05:07 +00:00
-- Legacy support
minetest.register_alias ( " mcl_core:tallgrass " , " mcl_flowers:tallgrass " )
2021-01-26 02:23:38 +00:00
-- mcimport support: re-adds missing double_plant tops in mcimported worlds.
local mg_name = minetest.get_mapgen_setting ( " mg_name " )
2021-05-29 14:12:33 +00:00
local mod_mcimport = minetest.get_modpath ( " mcimport " )
2021-01-26 02:23:38 +00:00
2021-05-29 14:12:33 +00:00
local fix_doubleplants = minetest.settings : get_bool ( " fix_doubleplants " , true )
2021-01-26 02:23:38 +00:00
2021-05-29 14:12:33 +00:00
if mod_mcimport and mg_name == " singlenode " and fix_doubleplants == true then
local flowernames = { " peony " , " rose_bush " , " lilac " , " sunflower " , " double_fern " , " double_grass " }
minetest.register_lbm ( {
label = " Add double plant tops. " ,
name = " mcl_flowers:double_plant_topper " ,
run_at_every_load = true ,
nodenames = { " mcl_flowers:peony " , " mcl_flowers:rose_bush " , " mcl_flowers:lilac " , " mcl_flowers:sunflower " , " mcl_flowers:double_fern " , " mcl_flowers:double_grass " } ,
action = function ( pos , node )
for c = 1 , 6 do
local flowername = flowernames [ c ]
local bottom = pos
local top = { x = bottom.x , y = bottom.y + 1 , z = bottom.z }
if node.name == " mcl_flowers: " .. flowername then
minetest.set_node ( top , { name = " mcl_flowers: " .. flowername .. " _top " } )
2021-01-26 02:23:38 +00:00
end
2021-05-29 14:12:33 +00:00
end
end ,
} )
end
2021-01-26 02:23:38 +00:00
2021-03-11 17:36:02 +00:00
dofile ( modpath .. " /register.lua " )