--Naturally generating nodes
minetest.register_node("main:stone", 
{
	description = "Stone",
	tiles = {"main_stone.png"},
	groups = {cracky = 1, stone = 1},
	drop = 'main:cobble',
	legacy_mineral = true,
})

minetest.register_node("main:cobble", 
{
	description = "Cobble",
	tiles = {"main_cobble.png"},
	groups = {cracky = 2, stone = 1},
	drop = 'main:cobble',
	legacy_mineral = true,
})

minetest.register_node("main:rock", 
{
	description = "Rock",
	tiles = {"main_cobble.png"},
	groups = {cracky = 3, stone = 1, oddly_breakable_by_hand = 3},
	drawtype = "nodebox",
	paramtype = "light",
	node_box =
	{
		type = "fixed",
		fixed =
		{
			{-0.25, -0.5, -0.25, 0.25, 0, 0.25},
		}
	}
})

minetest.register_node("main:dirt", 
{
	description = "Dirt",
	tiles = {"main_dirt.png"},
	groups = {crumbly = 3, soil = 1},
})

minetest.register_node("main:dirt_frozen", {
	description = "Frozen Dirt",
	tiles = {"main_dirt_frozen.png"},
	groups = {cracky = 1},
})

minetest.register_node("main:snow", {
	description = "Snow",
	tiles = {"main_snow.png"},
	groups = {crumbly = 3},
})

minetest.register_node("main:ice_thin", {
	drawtype = "allfaces",
	paramtype = "light",
	light_propagates = true,
	sunlight_propagates = true,
	alpha = 6,
	description = "Thin Ice",
	tiles = {"main_ice_thin.png"},
	groups = {cracky = 3, slippery = 3},
})

minetest.register_node("main:ice_thick", {
	description = "Thick Ice",
	tiles = {"main_ice_thick.png"},
	groups = {cracky = 1},
})

minetest.register_node("main:dirt_with_grass", 
{
	description = "Dirt with Grass",
	tiles = {"main_grass.png", "main_dirt.png",
		{name = "main_dirt.png^main_grass_side.png",
			tileable_vertical = false}},
	groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
	drop = 'main:dirt',
})

minetest.register_node("main:dirt_with_swamp_grass", 
{
	description = "Dirt with Swamp Grass",
	tiles = {"main_swamp_grass.png", "main_dirt.png",
		{name = "main_dirt.png^main_swamp_grass_side.png",
			tileable_vertical = false}},
	groups = {crumbly = 3, soil = 1, spreading_dirt_type = 1},
	drop = 'main:dirt',
})

minetest.register_node("main:sand",
{
	description = "Sand",
	tiles = {"main_sand.png"},
	groups = {crumbly = 3, falling_node = 1, sand = 1},
})

minetest.register_node("main:twig", 
{
	description = "Twig",
	tiles = {"main_log_maple.png"},
	groups = {choppy = 3, stone = 1, oddly_breakable_by_hand = 3},
	drawtype = "nodebox",
	paramtype = "light",
	drop = "main:stick",
	node_box =
	{
		type = "fixed",
		fixed =
		{
			{-0.125, -0.5, 0, 0.125, -0.3125, 0.1875}, -- NodeBox1
			{-0.4375, -0.5, 0.0625, -0.125, -0.3125, 0.25}, -- NodeBox3
			{0.125, -0.5, -0.0625, 0.5, -0.3125, 0.125}, -- NodeBox4
		}
	}
})

--Player made nodes
minetest.register_node("main:torch",
{
	description = "Torch",
	tiles = {"main_lump_coal.png"},
	light_source = 14,
	groups = {choppy = 3, oddly_breakable_by_hand = 3},
})

minetest.register_node("main:bricks_red", 
{
	description = "Red Bricks",
	tiles = {"main_bricks_red.png"},
	groups = {cracky = 2},
})

minetest.register_node("main:bricks_stone", 
{
	description = "Stone Bricks",
	tiles = {"main_bricks_stone.png"},
	groups = {cracky = 2},
})

minetest.register_node("main:bricks_cobble", 
{
	description = "Cobble Bricks",
	tiles = {"main_bricks_cobble.png"},
	groups = {cracky = 2},
})

minetest.register_node("main:glass",
{
    description = "Glass",
    drawtype = "glasslike_framed_optional",
    tiles = {"main_glass_frame.png", "main_glass.png"},
    inventory_image = minetest.inventorycube("main_glass_frame.png"),
    paramtype = "light",
    sunlight_propagates = true, 
	is_ground_content = false,
    groups = {cracky = 1, oddly_breakable_by_hand = 1},
})

--Ores
minetest.register_node("main:coal_ore", 
{
	description = "Coal Ore",
	tiles = {"main_stone.png^main_coal_ore.png"},
	groups = {cracky = 1},
})

minetest.register_node("main:iron_ore", 
{
	description = "Iron Ore",
	tiles = {"main_stone.png^main_iron_ore.png"},
	groups = {cracky = 3},
})

minetest.register_node("main:sulfur_ore", 
{
	description = "Sulfur Ore",
	tiles = {"main_stone.png^main_sulfur_ore.png"},
	groups = {cracky = 2},
})

minetest.register_node("main:salt_ore", 
{
	description = "Salt Ore",
	tiles = {"main_stone.png^main_salt_ore.png"},
	groups = {cracky = 3},
	drop = 'main:salt_crystals',
})

minetest.register_node("main:cinnabar_ore", 
{
	description = "Cinnabar",
	tiles = {"main_stone.png^main_cinnabar_ore.png"},
	groups = {cracky = 3},
})

--Diamond Ores
minetest.register_node("main:diamond_ore_lowdens", {
	description = "Low Density Diamond ore",
	tiles = {"main_stone.png^main_diamond_ore_lowdensity.png"},
	groups = {cracky = 3},
})

minetest.register_node("main:diamond_ore_hidens", {
	description = "High Density Diamond Ore",
	tiles = {"main_stone.png^main_diamond_ore.png"},
	groups = {cracky = 3},
})

--Iron Block
minetest.register_node("main:block_iron", {
	description = "Block Of Iron",
	tiles = {"main_block_iron.png"},
	groups = {cracky = 3},
	drop = 'main:block_iron',
})

--Copper Block
minetest.register_node("main:block_copper", {
	description = "Block Of Copper",
	tiles = {"main_block_copper.png"},
	groups = {cracky = 3},
})

--Brass Block
minetest.register_node("main:block_brass", {
	description = "Block Of Brass",
	tiles = {"main_block_brass.png"},
	groups = {cracky = 3},
})

--Gold Block
minetest.register_node("main:block_gold", {
	description = "Block Of Gold",
	tiles = {"main_block_gold.png"},
	groups = {cracky = 3},
})

--Planks
minetest.register_node("main:planks_oak", {
	description = "Planks",
	tiles = {"main_planks_oak.png"},
	groups = {choppy = 3},
})


--
-- Plants and Other Living Organisms
--

--Red Apple
minetest.register_node("main:apple_red", {
	description = "Red Apple",
	tiles = {"main_apple_red.png"},
	groups = {fleshy = 3, oddly_breakable_by_hand = 3},
	on_use = minetest.item_eat(5),
})

--Orange
minetest.register_node("main:orange", {
	description = "Orange",
	tiles = {"main_orange.png"},
	groups = {fleshy = 3, oddly_breakable_by_hand = 3},
	on_use = minetest.item_eat(4),
})



--Oak Log
minetest.register_node("main:log_oak", {
	description = "Oak Log",
	tiles = {"main_log_oak.png"},
	groups = {choppy = 2, logs = 1},
})

--Oak Leaves
minetest.register_node("main:leaves_oak", {
	paramtype = "light",
	light_propagates = true,
	sunlight_propagates = true,
	walkable = false,
	climbable = true,
	is_ground_content = false,
	description = "Oak Leaves",
	tiles = {"main_leaves_oak.png"},
	groups = {snappy = 3},
	waving = 1,
})

--Apple Tree Log
minetest.register_node("main:log_apple", {
	description = "Apple Tree Log",
	tiles = {"main_log_apple.png"},
	groups = {choppy = 3, logs = 1},
	waving = 1,
})

--Apple Tree Leaves
minetest.register_node("main:leaves_apple", {
	paramtype = "light",
	light_propagates = true,
	sunlight_propagates = true,
	walkable = false,
	climbable = true,
	is_ground_content = false,
	description = "Apple Tree Leaves",
	tiles = {"main_leaves_apple.png"},
	groups = {snappy = 3},
	waving = 1,
})

--
-- Liquids
--

--Fresh water
minetest.register_node("main:water_source", {
	description = "Fresh Water Source",
	drawtype = "liquid",
	paramtype = "light",
	
	tiles = {
		{
			name = "main_water_source_animated.png",
			animation = {
				type = "vertical_frames",
				aspect_w = 16,
				aspect_h = 16,
				length = 2.0,
			},
		},
	},
	alpha = 180,
	post_effect_color = {a = 50, r = 0, g = 50, b = 200},
	
	--Behavior
	walkable = false,
	pointable = false,
	buildable_to = true,
	diggable = false,
	is_ground_content = false,
	
	--Properties
	liquid_range = 14,
	liquid_viscosity = 0.1,
	drowning = 1,
	waving = 1,
	liquidtype = "source",
	liquid_alternative_flowing = "main:water_flowing",
	liquid_alternative_source = "main:water_source",
	groups = {liquid = 3, water = 1},
})

minetest.register_node("main:water_flowing", {
	description = "Flowing Water",
	drawtype = "flowingliquid",
	paramtype = "light",
	
	tiles = {
		{
			name = "main_water_flowing_animated.png",
			animation = {
				type = "vertical_frames",
				aspect_w = 16,
				aspect_h = 16,
				length = 2.0,
			},
		},
	},
	
	special_tiles = {
        {
            name = "main_water_flowing_animated.png",
            animation = {type = "vertical_frames", aspect_w = 16,
            aspect_h = 16, length = 2.0},
            backface_culling = true,
        },
        
        {
            name = "main_water_flowing_animated.png",
            animation = {type = "vertical_frames", aspect_w = 16,
            aspect_h = 16, length = 2.0},
            backface_culling = false,
        }
    },
	
	alpha = 180,
	post_effect_color = {a = 50, r = 0, g = 50, b = 200},
	
	--Behavior
	walkable = false,
	pointable = false,
	buildable_to = true,
	diggable = false,
	is_ground_content = false,
	
	--Properties
	liquid_range = 14,
	liquid_viscosity = 0.1,
	drowning = 1,
	waving = 1,
	liquidtype = "flowing",
	liquid_alternative_flowing = "main:water_flowing",
	liquid_alternative_source = "main:water_source",
	groups = {liquid = 3, water = 1},
})


stairs.register_stair_and_slab(
	"planks_oak",
	"main:planks_oak",
	{choppy = 2},
	{"main_planks_oak.png"},
	"Oak Plank Stair",
	"Oak Plank Slab",
	default.node_sound_wood_defaults(),
	true
)

stairs.register_stair_and_slab(
	"log_oak",
	"main:log_oak",
	{choppy = 2},
	{"main_log_oak.png"},
	"Oak Log Stair",
	"Oak Log Slab",
	default.node_sound_wood_defaults(),
	true
)