minetest.register_tool('epic:pick_titanium', {
   _doc_items_crafting = 'This tool is crafted in the Smithy Station.',
   description = 'Titanium Pickaxe',
   inventory_image = 'epic_tool_titanium_pick.png',
   _repair_material = 'epic:titanium_ingot',
   tool_capabilities = {
      full_punch_interval = 0.8,
      max_drop_level=3,
      groupcaps={
         cracky = {times={[1]=1.9, [2]=0.90, [3]=0.40}, uses=50, maxlevel=4},
      },
      damage_groups = {fleshy=10, knockback=3},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {pickaxe = 1}
})

minetest.register_tool('epic:shovel_titanium', {
   _doc_items_crafting = 'This tool is crafted in the Smithy Station.',
   description = 'Titanium Shovel',
   inventory_image = 'epic_tool_titanium_shovel.png',
   wield_image = 'epic_tool_titanium_shovel.png^[transformR90',
   _repair_material = 'epic:titanium_ingot',
   tool_capabilities = {
      full_punch_interval = 0.9,
      max_drop_level=3,
      groupcaps={
         crumbly = {times={[1]=1.0, [2]=0.40, [3]=0.20}, uses=50, maxlevel=4},
      },
      damage_groups = {fleshy=6},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {shovel = 1, knockback=2}
})

minetest.register_tool('epic:axe_titanium', {
   _doc_items_crafting = 'This tool is crafted in the Smithy Station.',
   description = 'Titanium Axe',
   inventory_image = 'epic_tool_titanium_axe.png',
   _repair_material = 'epic:titanium_ingot',
   tool_capabilities = {
      full_punch_interval = 0.8,
      max_drop_level=3,
      groupcaps={
         choppy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=50, maxlevel=4},
      },
      damage_groups = {fleshy=9, knockback=3},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {axe = 1}
})

minetest.register_tool('epic:sword_titanium', {
   _doc_items_crafting = 'This tool is crafted in the Smithy Station.',
   description = 'Titanium Sword',
   inventory_image = 'epic_tool_titanium_sword.png',
   _repair_material = 'epic:titanium_ingot',
   tool_capabilities = {
      full_punch_interval = 0.6,
      max_drop_level=3,
      groupcaps={
         snappy={times={[1]=1.80, [2]=0.80, [3]=0.20}, uses=60, maxlevel=4},
      },
      damage_groups = {fleshy=12, knockback=4},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {sword = 1}
})

minetest.register_tool('epic:shovel_soft', {
   description = 'Soft Touch Shovel',
   _doc_items_crafting = 'This tool is crafted in the Smithy Station.',
   _doc_items_durability = 111,
   _doc_items_longdesc = 'A special shovel that can pick up dirt blocks without disturbing the grass/moss.',
   _doc_items_usagehelp = "Punch a dirt block to pick it up.",
   inventory_image = 'epic_tool_shovel_soft.png',
   wield_image = 'epic_tool_shovel_soft.png^[transformR90',
   sound = {breaks = 'default_tool_breaks'},
   _repair_material = 'epic:titanium_ingot',
   groups = {shovel = 1, knockback=2},
   on_use = function(itemstack, user, pointed_thing)
      if pointed_thing.type == "node" then
         if not minetest.is_protected(pointed_thing.under, user:get_player_name()) then
            local pos = pointed_thing.under
            local nn = minetest.get_node(pos).name
            local is_crumbly = minetest.get_item_group(nn, "crumbly")
            if is_crumbly == 1 or is_crumbly == 2 or is_crumbly == 3 then
               local inv = user:get_inventory()
               minetest.env:remove_node(pointed_thing.under)
               minetest.check_for_falling(pos)
               inv:add_item("main", {name = nn})
               itemstack:add_wear(65535/100) -- 111 uses
               minetest.sound_play("default_dirt_footstep", {pos = pos, gain = 0.35})
               return itemstack
            end
         end
      end
   end,
})

minetest.register_tool('epic:pick_glowingdiamond', {
   _doc_items_crafting = 'This tool is crafted in the Crystal Workshop.',
   description = 'Glowingdiamond Pickaxe',
   inventory_image = 'epic_tool_glowingdiamond_pick.png',
   light_source = 13,
   _repair_material = 'epic:glowingdiamond',
   tool_capabilities = {
      full_punch_interval = 1.0,
      max_drop_level=2,
      groupcaps={
         cracky = {times={[1]=1.9, [2]=0.90, [3]=0.40}, uses=20, maxlevel=2},
      },
      damage_groups = {fleshy=4, knockback=3},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {pickaxe = 1}
})

minetest.register_tool('epic:shovel_glowingdiamond', {
   _doc_items_crafting = 'This tool is crafted in the Crystal Workshop.',
   description = 'Glowingdiamond Shovel',
   inventory_image = 'epic_tool_glowingdiamond_shovel.png',
   light_source = 13,
   wield_image = 'epic_tool_glowingdiamond_shovel.png^[transformR90',
   _repair_material = 'epic:glowingdiamond',
   tool_capabilities = {
      full_punch_interval = 1.1,
      max_drop_level=1,
      groupcaps={
         crumbly = {times={[1]=1.0, [2]=0.40, [3]=0.20}, uses=30, maxlevel=2},
      },
      damage_groups = {fleshy=3},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {shovel = 1, knockback=2}
})

minetest.register_tool('epic:axe_glowingdiamond', {
   _doc_items_crafting = 'This tool is crafted in the Crystal Workshop.',
   description = 'Glowingdiamond Axe',
   inventory_image = 'epic_tool_glowingdiamond_axe.png',
   light_source = 13,
   _repair_material = 'epic:glowingdiamond',
   tool_capabilities = {
      full_punch_interval = 1.0,
      max_drop_level=1,
      groupcaps={
         choppy={times={[1]=2.00, [2]=0.80, [3]=0.40}, uses=20, maxlevel=2},
      },
      damage_groups = {fleshy=4},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {axe = 1}
})

minetest.register_tool('epic:sword_glowingdiamond', {
   _doc_items_crafting = 'This tool is crafted in the Crystal Workshop.',
   description = 'Glowingdiamond Sword',
   inventory_image = 'epic_tool_glowingdiamond_sword.png',
   light_source = 13,
   _repair_material = 'epic:glowingdiamond',
   tool_capabilities = {
      full_punch_interval = 0.8,
      max_drop_level=1,
      groupcaps={
         snappy={times={[1]=1.80, [2]=0.80, [3]=0.20}, uses=30, maxlevel=2},
      },
      damage_groups = {fleshy=7, knockback=4},
   },
   sound = {breaks = 'default_tool_breaks'},
   groups = {sword = 1}
})

---RARE WEAPONS.
minetest.register_tool('epic:trident', {
   _doc_items_durability = 55,
   _doc_items_crafting = "This weapon can't be crafted or repaired.",
   description = 'Trident',
   inventory_image = 'epic_trident.png',
   tool_capabilities = {
      full_punch_interval = .5,
      max_drop_level = 2,
      damage_groups = {fleshy = 25, knockback = 2, rare = 1, attack_chance = 150},
      punch_attack_uses = 55,
   },
   groups = {not_in_creative_inventory=1}
})

minetest.register_tool('epic:slicer', {
   _doc_items_durability = 30,
   _doc_items_crafting = "This weapon can't be crafted or repaired.",
   description = 'Decapitating Obsidian Slicer',
   inventory_image = 'epic_slicer.png',
   tool_capabilities = {
      full_punch_interval = .8,
      max_drop_level = 3,
      damage_groups = {fleshy = 36, knockback = 4, rare = 1, attack_chance = 175},
      punch_attack_uses = 30,
   },
   groups = {not_in_creative_inventory=1}
})

minetest.register_tool('epic:reaver', {
   _doc_items_durability = 50,
   _doc_items_crafting = "This weapon can't be crafted or repaired.",
   description = 'Skullforge Reaver',
   inventory_image = 'epic_reaver.png',
   tool_capabilities = {
      full_punch_interval = .2,
      max_drop_level = 2,
      damage_groups = {fleshy = 16, knockback = 3, rare = 1, attack_chance = 150},
      punch_attack_uses = 50,
   },
   groups = {not_in_creative_inventory=1}
})

toolranks.add_tool("epic:sword_titanium")
toolranks.add_tool("epic:sword_glowingdiamond")
toolranks.add_tool("epic:pick_titanium")
toolranks.add_tool("epic:pick_glowingdiamond")
toolranks.add_tool("epic:axe_titanium")
toolranks.add_tool("epic:axe_glowingdiamond")
toolranks.add_tool("epic:shovel_titanium")
toolranks.add_tool("epic:shovel_glowingdiamond")
toolranks.add_tool("epic:shovel_soft")

--[[
--------------------------
This code needs to be put into mobs_redo to handle the rare weapons wearing faster.
-- toolrank support
local wear = 0
if tool_capabilities.damage_groups['rare'] then
   local uses = tool_capabilities.punch_attack_uses
   wear = floor(65535/uses)
else
   wear = floor((punch_interval / 75) * 9000)
end
--]]
