minetest.register_tool("default:pick_admin", {
	description = "Admin Pickaxe",
	range = 12,
	inventory_image = "default_adminpick.png",
	--groups = {not_in_creative_inventory = default.creative},
	tool_capabilities = {
		full_punch_interval = 0.1,
		max_drop_level = 3,
		groupcaps= {
			unbreakable = {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			fleshy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			choppy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			bendy =       {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			cracky =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			crumbly =     {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			snappy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
		},
		damage_groups = {fleshy = 1000},
	},
})

minetest.register_tool("default:pick_admin_with_drops", {
	description = "Admin Pickaxe with Drops",
	range = 12,
	inventory_image = "default_adminpick_with_drops.png",
	--groups = {not_in_creative_inventory = default.creative},
	tool_capabilities = {
		full_punch_interval = 0.35,
		max_drop_level = 3,
		groupcaps = {
			unbreakable = {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			fleshy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			choppy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			bendy =       {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			cracky =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			crumbly =     {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
			snappy =      {times={[1] = 0, [2] = 0, [3] = 0}, uses = 0, maxlevel = 3},
		},
		damage_groups = {fleshy = 1000},
	},
})

minetest.register_on_punchnode(function(pos, node, puncher)
	if puncher:get_wielded_item():get_name() == "default:pick_admin"
	and minetest.get_node(pos).name ~= "air" then
		minetest.log("action", puncher:get_player_name() .. " digs " .. minetest.get_node(pos).name .. " at " .. minetest.pos_to_string(pos) .. " using an Admin Pickaxe.")
		minetest.remove_node(pos) -- The node is removed directly, which means it even works on non-empty containers and group-less nodes.
		nodeupdate(pos) -- Run node update actions like falling nodes.
	end
end)



local build_air_place = function(itemstack, player, pointed_thing)
		local inv = player:get_inventory()
		local nname = inv:get_stack("main", player:get_wield_index()+1):get_name()
		if not nname then return end
		local def = minetest.registered_items[nname]
		if not def or  def.type ~= "node" then return end
		local ppos = player:getpos()
		
		
		
		
--<bad code> 
		--local dir = math.floor(player:get_look_yaw()+math.pi)
		local dir = minetest.facedir_to_dir(math.ceil(player:get_look_yaw()+math.pi)  )
		if not dir then return end
print("ppos:"..dump(ppos).."   :"..dump(dir))
	local p = {x=ppos.x+dir.x, y=ppos.y, z=ppos.z+dir.z}
	--local p = vector.add(ppos, dir)
print("p:"..dump(p))
--</bad code>




	local n2 = minetest.get_node_or_nil(p)
	if not n2 or n2.name ~= "air" then return end
	minetest.set_node(p, {name = nname})
	minetest.sound_play("default_place_node", {pos=ppos})
	if not minetest.setting_getbool("creative_mode") then
		inv:remove_item("main", nname)
	end
end


--tools to build on air
minetest.register_tool("default:build_air", {
	description = "Build Air Tool",
	inventory_image = "default_build_air.png",
	stack_max = 1,
	on_use = function(itemstack, user, pointed_thing)
		build_air_place(itemstack, user, pointed_thing)
	end,
})

