
minetest.register_tool("infinity:duplicator", {
	description = "Duplicate Your Blocks",
	inventory_image = "infinity_duplicator.png",
	range = 10000,
on_place = function(itemstack, player, pointed_thing)
	if pointed_thing.type == "node" then
		local node = minetest.get_node(pointed_thing.under)
		local node_name = node.name
		local select_pos = pointed_thing.under
	if node.name == "infinity:space_chest" or node.name == "infinity:soul_wall" or node.name == "default:diamondblock" or node.name == "air" or node.name == "default:snow" or node.name == "infinity:stonesoul" or node.name == "infinity:stonereality" or node.name == "infinity:stonespace" or node.name == "infinity:stonepower" or node.name == "infinity:stonetime" or node.name == "infinity:stonemind" or node.name == "tardis_new:tardis" or node.name == "infinity:soulworld" then
else
RYB = node_name
minetest.chat_send_player(player:get_player_name(), "Copied ".. RYB)
end
end
end,

on_use = function(itemstack, player, pointed_thing, pos)
	if pointed_thing.type == "node" then
		if RYB == nil then
		else
		local node = minetest.get_node(pointed_thing.under)
		local select_pos = pointed_thing.under
	if node.name == "infinity:space_chest" or node.name == "infinity:soul_wall" or node.name == "infinity:in_door" or node.name == "default:diamondblock" or node.name == "tardis_new:tardis" or node.name == "infinity:soulworld" or node.name == "default:snow" or node.name == "infinity:stonesoul" or node.name == "infinity:stonereality" or node.name == "infinity:stonespace" or node.name == "infinity:stonepower" or node.name == "infinity:stonetime" or node.name == "infinity:stonemind" then
			else
			minetest.set_node(select_pos, {name = "".. RYB})


    minetest.add_particle({
        pos = {x=select_pos.x, y=select_pos.y+1, z=select_pos.z}, -- Position of the particle
        velocity = {x=-1, y=0, z=1}, -- Velocity of the particle
        acceleration = {x=1, y=0, z=-1}, -- Acceleration of the particle
        expirationtime = 1.25, -- Time after which the particle disappears
        size = 4.5, -- Size of the particle
        collisiondetection = true, -- Whether the particle collides with nodes
        texture = "infinity_particle.png", -- Texture of the particle
    })
    minetest.add_particle({
        pos = {x=select_pos.x, y=select_pos.y+1, z=select_pos.z}, -- Position of the particle
        velocity = {x=1, y=0, z=-1}, -- Velocity of the particle
        acceleration = {x=-1, y=0, z=1}, -- Acceleration of the particle
        expirationtime = .75, -- Time after which the particle disappears
        size = 3, -- Size of the particle
        collisiondetection = true, -- Whether the particle collides with nodes
        texture = "infinity_particle.png", -- Texture of the particle
    })
    minetest.add_particle({
        pos = {x=select_pos.x, y=select_pos.y+1, z=select_pos.z}, -- Position of the particle
        velocity = {x=2, y=-1, z=2}, -- Velocity of the particle
        acceleration = {x=2, y=-1, z=2}, -- Acceleration of the particle
        expirationtime = 1, -- Time after which the particle disappears
        size = 2, -- Size of the particle
        collisiondetection = true, -- Whether the particle collides with nodes
        texture = "infinity_particle.png", -- Texture of the particle
    })
    minetest.add_particle({
        pos = {x=select_pos.x, y=select_pos.y+1, z=select_pos.z}, -- Position of the particle
        velocity = {x=2, y=-1, z=-2}, -- Velocity of the particle
        acceleration = {x=-2, y=1, z=2}, -- Acceleration of the particle
        expirationtime = .5, -- Time after which the particle disappears
        size = 3.5, -- Size of the particle
        collisiondetection = true, -- Whether the particle collides with nodes
        texture = "infinity_particle.png", -- Texture of the particle
    })
			end
		end
	end
end
})

local GCB = 1
minetest.register_tool("infinity:time_key",{
		description = "Changes Your Speed(Right-Click to Speed Up and Left-Click to Slow Down)",
		inventory_image = "infinity_time_key.png",
		groups = {},
    on_place = function(itemstack, player)

        GCB = GCB + 0.5
	if GCB > 10 then
	    GCB = 10
     	minetest.chat_send_player(player:get_player_name(), "Maximum amount of speed reached.")	
	end
      	minetest.chat_send_player(player:get_player_name(), "Speed set to ".. GCB)
        player:set_physics_override({speed = GCB})
        return itemstack
end,

    on_use = function(itemstack, player, user)
        GCB = GCB - 0.5
	if GCB < 1 then
	    GCB = 1
     	minetest.chat_send_player(player:get_player_name(), "Minimum amount of speed reached.")	
	end
      	minetest.chat_send_player(player:get_player_name(), "Speed set to ".. GCB)
        player:set_physics_override({speed = GCB})
        return itemstack
    end,
})

minetest.register_tool("infinity:time_clock", {
	description = ("Empowered by the Time Stone.(Right-Click for Day, Left-Click for Night) "),
	inventory_image = "infinity_day_orb.png",
	range=1000,
	liquid_pointable = true,
	groups = { tool=1 },
	on_use = function(itemstack, user)
		minetest.set_timeofday(0)
		return itemstack
	end,
	on_place = function(itemstack, placer)
		minetest.set_timeofday(0.5)
		return itemstack
	end
})

minetest.register_tool("infinity:power_sword", {
    description = ("Power Sword"),
    inventory_image = "infinity_power_sword.png",
    light_source = 100,
	tool_capabilities = {
		full_punch_interval = full_punch_interval,
		max_drop_level = 3,
		groupcaps = {
			fleshy = {times = {[2] = 0.65, [3] = 0.25}, uses = 10000000000000000000000000000000000, maxlevel = 5},
			snappy = {times = {[1]=1.00, [2]=0.50, [3]=0.75},uses = 10000000000000000000000000000000000, maxlevel = 5},
			choppy = {times = {[3] = 0.65}, uses = 10000000000000000000000000000000000, maxlevel = 5},
		},
		damage_groups = {fleshy = 10000},
	},
	groups = {sword = 1}
})

	armor:register_armor("infinity:soul_helmet_soul", {
		description = "Soul Helmet",
		inventory_image = "infinity_inv_helmet_crystal.png",
		groups = {armor_head=1000000000000000000000, armor_heal=1200000000000000000000, armor_use=1000000000000000000000000000000, armor_fire=1000000000000000000000},
	armor_groups = {fleshy=15000000000000000000000000000000},
	damage_groups = {cracky=200000000000000000000, snappy=1000000000000000000000, level=3000000000000000000},
	light_source = 100,
	})

minetest.register_on_joinplayer(function(player)
    local inv = player:get_inventory()
    if inv:contains_item("main", "infinity:player") then
        inv:remove_item("main", "infinity:player")
        inv:add_item("main", "infinity:thanos")
    end
end)

minetest.register_tool("infinity:thanos", {
    description = "Become Thanos (Right Click)",
    inventory_image = "infinity_thanosinv.png",
    range = 1000,
    on_use = function(itemstack, user, pointed_thing)
        local player_name = user:get_player_name()
        local skin = "infinity_thanos.png"  -- Replace with your desired skin file
        local player = minetest.get_player_by_name(player_name)
        
        -- Change the player's skin
        player:set_properties({
            textures = {skin},

        })
        	user:set_hp(20)
        player:set_wielded_item("infinity:player")
    end,
})

minetest.register_tool("infinity:player", {
    description = "Become Human Again (Right-Click)",
    inventory_image = "infinity_playerinv.png",
    range = 10000,
    groups = {not_in_creative_inventory = 1},
    on_use = function(itemstack, user, pointed_thing)
        local player_name = user:get_player_name()
        local skin = "character.png"  -- Replace with your desired skin file
        local player = minetest.get_player_by_name(player_name)
        
        -- Change the player's skin
        player:set_properties({
            textures = {skin},

        })
        	user:set_hp(20)
        user:set_wielded_item("infinity:thanos")
    end,
})
