minetest.register_node("nalc_flowers:lily_pad", {
	description = "Lily Pad",
	drawtype = "nodebox",
	tiles = { "flowers_lily_pad.png" },
	inventory_image = "flowers_lily_pad.png",
	wield_image = "flowers_lily_pad.png",
	wield_scale = {x = 1, y = 1, z = 0.001},
	sunlight_propagates = true,
	paramtype = "light",
	paramtype2 = "facedir",
	liquids_pointable = true,
	walkable = false,
	buildable_to = true,
	floodable = true,
	groups = {snappy = 3, flammable = 2, flower = 1},
	sounds = default.node_sound_leaves_defaults(),
	node_placement_prediction = "",
	node_box = {
		type = "fixed",
		fixed = {-0.5, -0.45, -0.5, 0.5, -0.4375, 0.5},
	},
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5},
	},
	on_place = function(itemstack, placer, pointed_thing)
		local pos = pointed_thing.above
		local node = minetest.get_node(pointed_thing.under)
		local def = minetest.registered_nodes[node.name]
		local player_name = placer and placer:get_player_name() or ""

		if def and def.on_rightclick then
			return def.on_rightclick(pointed_thing.under, node, placer, itemstack,
					pointed_thing)
		end

		if def and def.liquidtype == "source" and
				minetest.get_item_group(node.name, "water") > 0 then
			if not minetest.is_protected(pos, player_name) then
				minetest.set_node(pos, {name = "nalc_flowers:lily_pad",
					param2 = math.random(0, 3)})
				if not (creative and creative.is_enabled_for
						and creative.is_enabled_for(player_name)) then
					itemstack:take_item()
				end
			else
				minetest.chat_send_player(player_name, "Node is protected")
				minetest.record_protection_violation(pos, player_name)
			end
		end

		return itemstack
	end
})

minetest.register_decoration({
	deco_type = "schematic",
	place_on = {"default:dirt"},
	sidelen = 16,
	noise_params = {
		offset = -0.12,
		scale = 0.31,
		spread = {x=200, y=200, z=200},
		seed = 33,
		octaves = 3,
		persist = 0.7
	},
	biomes = {"rainforest_swamp", "savanna_shore", "deciduous_forest_shore"},
	y_min = 0,
	y_max = 0,
	schematic = minetest.get_modpath("nalc_flowers").."/schematics/lilypad.mts",
	rotation = "random",
})

minetest.register_alias("flowers:lily_pad", "nalc_flowers:lily_pad")
minetest.register_alias("nalc:lily_pad", "nalc_flowers:lily_pad")

minetest.log("action", "[nalc_flowers] loaded.")
