aom_elemental.magma = {}
function aom_elemental.magma.do_sound(self, name, gain)
    minetest.sound_play(("aom_elementals_"..name), {
        gain = gain or 1,
        pos = self.object:get_pos(),
        object = self.object,
    })
end

local animspeedmult = 0.7


if true then
    local stone = minetest.registered_entities["aom_elementals:stone"]
    local mag = table.copy(stone)

    mag.initial_properties = table.copy(mag.initial_properties)
    mag.initial_properties.textures = {"aom_elemental_magma.png"}
    mag.initial_properties.glow = 3
    mag.name = "aom_elementals:magma"
    mag._drop = {
        max_items = 8,
        items = {
            {
                rarity = 5,
                items = {"aom_elementals:elemental_core_magma"},
            },
            {
                rarity = 5,
                items = {"aom_underworld:lava_coral"},
            },
            {
                rarity = 2,
                items = {"aom_underworld:lava_brick_ornate 3"},
            },
            {
                rarity = 2,
                items = {"aom_underworld:lava_brick 3"},
            },
            {
                rarity = 2,
                items = {"aom_underworld:lava_rock 5"},
            },
            {
                rarity = 5,
                items = {"aom_underworld:cortite"},
            },
            {
                rarity = 50,
                items = {"aom_underworld:mythril"},
            },
        }
    }

    mag._aom_speed = mag._aom_speed / animspeedmult
    mag._aom_acceleration = 10
    mag._knockback = 0.1
    mag._damagemult = 2
    mag._knockbackmult = 2

    for i, anim in pairs(mag._animations) do
        mag._animations[i] = table.copy(anim)
        mag._animations[i].speed = (mag._animations[i].speed or 24) / animspeedmult
    end

    minetest.register_entity("aom_elementals:magma", mag)
end


minetest.register_craftitem("aom_elementals:magma_spawn",
{
    description = "magma Elemental spawn egg",
    inventory_image = "aom_elemental_stone.png",
    on_place = function(itemstack, placer, pointed_thing)
        local ent = minetest.add_entity(vector.offset(minetest.get_pointed_thing_position(pointed_thing), 0, 1, 0), "aom_elementals:magma")
    end,
})
