minetest.register_node("amogus_blocks:ladder_steel", {
	description = "Ladder",
	drawtype = "signlike",
	tiles = {"ladder.png"},
	paramtype = "light",
	paramtype2 = "wallmounted",
	sunlight_propagates = true,
	walkable = false,
	climbable = true,
	is_ground_content = false,
	selection_box = {
		type = "wallmounted",
	},
	groups = {cracky = 2},
})

minetest.register_node("amogus_blocks:tv", {
	description = "CRT TV",
	tiles = {
		"crt2.png", 
		"crt2.png",
		"crt2.png",
		"crt2.png",
		"crt2.png",
		"crt.png"
	},
	paramtype2 = "facedir",
	drop = 'amogus_blocks:amogus_blocks', groups = {stone=3},
})

minetest.register_node("amogus_blocks:bricks", {
	description = "Red Bricks",
	tiles = {"Bricks.png"},
	
	drop = 'amogus_blocks:bricks', groups = {stone=3},
})
minetest.register_node("amogus_blocks:grey_bricks", {
	description = "Bricks",
	tiles = {"Bricks2.png"}, groups = {stone=3},
	
	drop = 'amogus_blocks:grey_bricks',
})
minetest.register_node("amogus_blocks:blue_bricks", {
	description = "blue Bricks",
	tiles = {"Bricks_blue.png"}, groups = {stone=3},
	
	drop = 'amogus_blocks:blue_bricks',
})
minetest.register_node("amogus_blocks:yellow_bricks", {
	description = "yellow Bricks",
	tiles = {"Bricks_yellow.png"}, groups = {stone=3},
	
	drop = 'amogus_blocks:yellow_bricks',
})
minetest.register_node("amogus_blocks:green_bricks", {
	description = "green Bricks",
	tiles = {"Bricks_green.png"}, groups = {stone=3},
	
	drop = 'amogus_blocks:green_bricks',
})
minetest.register_node("amogus_blocks:black_bricks", {
	description = "black Bricks",
	tiles = {"Bricks_black.png"}, groups = {stone=3},
	
	drop = 'amogus_blocks:black_bricks',
})
minetest.register_node("amogus_blocks:planks", {
	description = "Planks",
	tiles = {"Planks.png"},
	
	drop = 'amogus_blocks:planks', groups = {choppy = 3},
})
minetest.register_node("amogus_blocks:purpleblock", {
	description = "Purple Block",
	tiles = {"purpleblock.png"},
	
	drop = 'amogus_blocks:purpleblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:blueblock", {
	description = "Blue Block",
	tiles = {"blue.png"},
	
	drop = 'amogus_blocks:blueblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:yellowblock", {
	description = "Yellow Block",
	tiles = {"yellow.png"},
	
	drop = 'amogus_blocks:yellowblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:greenblock", {
	description = "Green Block",
	tiles = {"greenblock.png"},
	
	drop = 'amogus_blocks:greenblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:blackblock", {
	description = "Black Block",
	tiles = {"blackblock.png"},
	
	drop = 'amogus_blocks:blackblock', groups = {crumbly = 3},
})minetest.register_node("amogus_blocks:whiteblock", {
	description = "White Block",
	tiles = {"whiteblock.png"},
	
	drop = 'amogus_blocks:whiteblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:redblock", {
	description = "Red Block",
	tiles = {"redblock.png"},
	
	drop = 'amogus_blocks:redblock', groups = {crumbly = 3},
})
minetest.register_node("amogus_blocks:glowing_block", {
	description = "Glowing Block",
	tiles = {"glowing_block.png"},
	
	drop = 'amogus_blocks:glowing_block', groups = {cracky=3, stone=1},
	light_source = 14
})

minetest.register_node("amogus_blocks:transparent", {
    description = "Glass",
    drawtype = "glasslike",
    tiles = {"glass.png"},
    paramtype = "light",
    is_ground_content = false,
    sunlight_propagates = true,
    groups = {cracky=3,oddly_breakable_by_hand=3},
})

minetest.register_node("amogus_blocks:grass", {
    description = "Grass",
    tiles = {
		"g2.png", 
		"d.png",
		"g.png",
		"g.png",
		"g.png",
		"g.png"
	},
    
	drop = {
		max_items = 2,
		items = {
			{
				items = {'amogus_blocks:dirt 5'},
				rarity = 3,
			},
			{
				items = {'amogus_items:rock'},
				rarity = 2,
			},
		},
	}, groups = {crumbly=3},
})

minetest.register_node("amogus_blocks:grass_green", {
    description = "Grass",
    tiles = {
		"grass_greentop.png", 
		"d.png",
		"grass_greenside.png",
		"grass_greenside.png",
		"grass_greenside.png",
		"grass_greenside.png"
	},
    
	drop = {
		max_items = 2,
		items = {
			{
				items = {'amogus_blocks:dirt'},
				rarity = 3,
			},
			{
				items = {'amogus_items:rock'},
				rarity = 2,
			},
		},
	}, groups = {crumbly=3},
})


minetest.register_node("amogus_blocks:wood", {
    description = "Wood",
    tiles = {"wood.png"},
    
    drop = 'amogus_items:wooden_plank',
	groups = {choppy = 3, flammable = 3, wood = 1},
})


-- OLD water. not flowing. throwing massive amounts of errors.

--minetest.register_node("amogus_blocks:water", {
--	description = "Water",
--	drawtype = "liquid",
--	tiles = {
--		{
--			name = "water.png",
--			--animation = {
--			--	type = "vertical_frames",
--			--	aspect_w = 16,
--			--	aspect_h = 16,
--			--	length = 2.0,
--			--},
--		},
--		--{
--		--	name = "water.png",
--		--	animation = {
--		--		type = "vertical_frames",
--		--		aspect_w = 16,
--		--		aspect_h = 16,
--		--		length = 2.0,
--		--	},
--		--},
--	},
--	--special_tiles = {
--	--	-- New-style water source material (mostly unused)
--	--	{
--	--		name = "water.png",
--	--		backface_culling = false,
--	--		animation = {
--	--			type = "vertical_frames",
--	--			aspect_w = 16,
--	--			aspect_h = 16,
--	--			length = 2.0,
--	--		},
--	--	},
--	--	-- New-style flowing water material (mostly unused)
--	--	{
--	--		name = "water.png",
--	--		backface_culling = true,
--	--		animation = {
--	--			type = "vertical_frames",
--	--			aspect_w = 16,
--	--			aspect_h = 16,
--	--			length = 0.8,
--	--		},
--	--	},
--	--},
--	alpha = 160,
--	paramtype = "light",
--	walkable = false,
--	pointable = false,
--	diggable = false,
--	--buildable_to = true,
--	drowning = 1,
--	liquidtype = "source",
--	--liquid_alternative_flowing = "amogus_blocks:water_flowing",
--	--liquid_alternative_source = "amogus_blocks:water_source",
--	liquid_viscosity = 1,
--	post_effect_color = {a = 103, r = 30, g = 60, b = 90},
--	groups = {water = 3, liquid = 3, puts_out_fire = 1},
--})



minetest.register_node("amogus_blocks:water_source", {
	description = "Water Source",
	drawtype = "liquid",
	waving = 3,

	tiles = {
		{
			name = "water.png^[opacity:127]",
			backface_culling = false,
		},
		{
			name = "water.png^[opacity:127]",
			backface_culling = true,
		},
	},

	use_texture_alpha = "blend",
	paramtype = "light",
	walkable = false,
	pointable = false,
	diggable = false,
	buildable_to = true,
	is_ground_content = false,
	drop = "",
	drowning = 1,
	liquidtype = "source",
	liquid_alternative_flowing = "amogus_blocks:water_flowing",
	liquid_alternative_source = "amogus_blocks:water_source",
	liquid_viscosity = 1,
	post_effect_color = {a = 103, r = 30, g = 60, b = 90},
	groups = {water = 3, liquid = 3, cools_lava = 1}
})

minetest.register_node("amogus_blocks:water_flowing", {
	description = "Flowing Water",
	drawtype = "flowingliquid",
	waving = 3,

	tiles = {"water.png^[opacity:127]"},
	special_tiles = {
		{
			name = "water.png^[opacity:127]",
			backface_culling = false,
		},
		{
			name = "water.png^[opacity:127]",
			backface_culling = true,
		},
	},
	
	use_texture_alpha = "blend",
	paramtype = "light",
	paramtype2 = "flowingliquid",
	walkable = false,
	pointable = false,
	diggable = false,
	buildable_to = true,
	is_ground_content = false,
	drop = "",
	drowning = 1,
	liquidtype = "flowing",
	liquid_alternative_flowing = "amogus_blocks:water_flowing",
	liquid_alternative_source = "amogus_blocks:water_source",
	liquid_viscosity = 1,
	post_effect_color = {a = 103, r = 30, g = 60, b = 90},
	groups = {water = 3, liquid = 3, not_in_creative_inventory = 1, cools_lava = 1}
})

minetest.register_node("amogus_blocks:dirt", {
	description = "Dirt",
	tiles = {"d.png"},
	groups = {crumbly = 3},

	drop = {
		max_items = 2,
		items = {
			{
				items = {'amogus_blocks:dirt'},
				rarity = 3,
			},
			{
				items = {'amogus_items:rock'},
				rarity = 2,
			},
		},
	},

})minetest.register_node("amogus_blocks:sand", {
	description = "Sand",
	tiles = {"sand.png"},
	groups = {crumbly = 3},
})

minetest.register_node("amogus_blocks:stone", {
	description = "Stone",
	tiles = {"stone.png"},
	drop = 'amogus_items:rock 9',
	
	groups = {stone = 3},
})

--add gold ore and sussium ore 

minetest.register_node("amogus_blocks:gold_ore", {
	description = "Gold Ore",
	tiles = {"gold.png"},
	groups = {stone = 2},
	drop = 'amogus_items:gold_ingot',
	--sounds = default.node_sound_stone_defaults(),
})

minetest.register_node("amogus_blocks:sussium_ore", {
	description = "Sussium Ore",
	tiles = {"sussium.png"},
	groups = {stone = 1},
	drop = 'amogus_items:sussium_ingot',
	--sounds = default.node_sound_stone_defaults(),
})

local loot = {
    "amogus_items:amogus",
    "amogus_items:sprite",
    "amogus_items:coke",
    "amogus_items:fanta",
    "amogus_items:tomato",
    "amogus_items:lightsaber_blue",
    "amogus_items:lightsaber_red",
    "amogus_items:lightsaber_green",
}

minetest.register_node("amogus_blocks:lucky_block", {
    description = "Lucky Block",
    tiles = {"luckyblock.png"},
	
    groups = {cracky = 3},
    on_punch = function(pos, node, puncher, pointed_thing)
        local item = loot[math.random(#loot)]
        minetest.add_item(pos, item)
		minetest.add_particlespawner({
			amount = 100,
			time = 0.1,
			minpos = pos,
			maxpos = pos,
			minvel = {x = -1, y = 5, z = -1},
			maxvel = {x = 1, y = 5, z = 1},
			minacc = {x = 0, y = -10, z = 0},
			maxacc = {x = 0, y = -10, z = 0},
			minexptime = 0.1,
			maxexptime = 0.5,
			minsize = 1,
			maxsize = 2,
			collisiondetection = true,
			vertical = false,
			texture = "luckyblock.png",
		})
        minetest.remove_node(pos)

    end
})

minetest.register_node("amogus_blocks:amogus_spawner", {
    description = "Amogus Spawner",
    tiles = {"spawner.png"},
	
    drawtype = "glasslike",
    paramtype = "light",
    is_ground_content = false,
    sunlight_propagates = true,
	-- after place event
    --on_ = function(pos)

	on_construct = function(pos)
        local meta = minetest.get_meta(pos)
        meta:set_int("spawned", 0)
        meta:set_int("interval", math.random(1,4))
        minetest.get_node_timer(pos):start(meta:get_int("interval"))
    end,
    on_timer = function(pos)
        local meta = minetest.get_meta(pos)
        local spawned = meta:get_int("spawned")
        if spawned < 30 then
            minetest.add_entity({x = pos.x, y = pos.y + 1, z = pos.z}, "amogus_entities:amogus")
			minetest.add_particlespawner({
				amount = 1000,
				time = 0.3,
				minpos = pos,
				maxpos = pos,
				minvel = {x = -1, y = 5, z = -1},
				maxvel = {x = 1, y = 5, z = 1},
				minacc = {x = 0, y = -10, z = 0},
				maxacc = {x = 0, y = -10, z = 0},
				minexptime = 0.1,
				maxexptime = 0.5,
				minsize = 1,
				maxsize = 2,
				collisiondetection = true,
				vertical = false,
				texture = "amog_flower.png",
			})
            spawned = spawned + 1
            meta:set_int("spawned", spawned)
            minetest.get_node_timer(pos):start(meta:get_int("interval"))
        else
            minetest.remove_node(pos)
        end
    end
})

minetest.register_node("amogus_blocks:green_leaves", {
    description = "Green Leaves",
    drawtype = "glasslike",
    tiles = {"leaves.png"},
    paramtype = "light",
    is_ground_content = false,
    sunlight_propagates = true,
    groups = {cracky=3,oddly_breakable_by_hand=3},
})

minetest.register_node("amogus_blocks:grass_tall", {
	description = "Grass plant",
	drawtype = "plantlike",
	tiles = {"grass_tall.png"},
	inventory_image = "grass_tall.png",
	wield_image = "grass_tall.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy=3,flammable=2,flower=1},
	--sounds = default.node_sound_leaves_defaults(),
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
	},

})
minetest.register_node("amogus_blocks:purple_grass_tall", {
	description = "Grass plant",
	drawtype = "plantlike",
	tiles = {"purple_grass_tall.png"},
	inventory_image = "purple_grass_tall.png",
	wield_image = "purple_grass_tall.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy=3,flammable=2,flower=1},
	--sounds = default.node_sound_leaves_defaults(),
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
	},
})
minetest.register_node("amogus_blocks:amogflower", {
	description = "amogus flower",
	drawtype = "plantlike",
	tiles = {"amog_flower.png"},
	inventory_image = "amog_flower.png",
	wield_image = "amog_flower.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	light_source = 14,
	groups = {snappy=3,flammable=2,flower=1},
	--sounds = default.node_sound_leaves_defaults(),
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
	},
})
minetest.register_node("amogus_blocks:redflower", {
	description = "red flower",
	drawtype = "plantlike",
	tiles = {"flower.png"},
	inventory_image = "flower.png",
	wield_image = "flower.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy=3,flammable=2,flower=1},
	--sounds = default.node_sound_leaves_defaults(),
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
	},
})
minetest.register_node("amogus_blocks:yellowflower", {
	description = "yellow flower",
	drawtype = "plantlike",
	tiles = {"flower_2.png"},
	inventory_image = "flower_2.png",
	wield_image = "flower_2.png",
	paramtype = "light",
	sunlight_propagates = true,
	walkable = false,
	groups = {snappy=3,flammable=2,flower=1},
	--sounds = default.node_sound_leaves_defaults(),
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -5/16, 0.5},
	},
})


minetest.register_node("amogus_blocks:obsusian", {
	description = "obSUSian",
	tiles = {"obsusian.png"},
	
	groups = {stone=0.5},
})


-- create golden, sussium block
minetest.register_node("amogus_blocks:sussium_block", {
	description = "SUSsium block",
	tiles = {"sussium_block.png"},
	
	groups = {stone=1},
})
minetest.register_node("amogus_blocks:golden_block", {
	description = "golden block",
	tiles = {"golden_block.png"},
	
	groups = {stone=2},
})
