function deleteKeyAndUpdateState(c, keyToDelete) {
    // Получаем текущее состояние
    var states = c.getServer().getStates();
    var currentStateString = states.getString("state_1");
    
    // Удаляем ключ из строки
    var newStateString = deleteKeyFromString(currentStateString, keyToDelete);
    
    // Обновляем state_1 с новой строкой
    states.setString("state_1", newStateString);
    
    // Выводим новое состояние для проверки
    c.send("Updated state_1:", newStateString);
}

function main(c)
{   
    var states = c.getServer().getStates();
    var str = states.getString("state_1");
    var s = c.getSubject();
    var result = parseKeyValueString(str);
    
    var displayNames = Object.keys(result);
    var ui = mappet.createUI(c, "handler").background();
    var strings = ui.stringList(displayNames).id("strings").tooltip("Нажмите для получения информации...");
    var label = ui.label("...").id("fruit").visible(false);
    var layout = ui.layout();
    layout.getCurrent().rxy(0.5, 0.5).wh(400, 400).anchor(0.5);
    var morph = mappet.createMorph("{Skin:\"b.a:empty/skins/texture.png\",Settings:{Hands:1b},Name:\"blockbuster.empty\"}");
    var char = layout.morph(morph).id("char")
    char.rxy(0.5, 0.45).wh(250, 340).anchor(0.5).position(0.027, 1.4, 0.019).rotation(0, -35).distance(2.5).fov(65).enabled(true);
     var takeButton = ui.button("Забрать").id("take").background(0x426242);
    
    takeButton.rxy(0.5, 0.9).wh(100, 20).anchor(0.5);

    strings.background(0x88000000).rxy(0.3, 0.5).wh(100, 240).anchor(0.5);
    label.rx(0.5).ry(0.5, -160).anchor(0.5, 0.5);
    label.background(0x28000000).labelAnchor(0.5, 0.5);
    s.openUI(ui);
}

function handler(c)
{    
    var states = c.getServer().getStates();
    var str = states.getString("state_1");
    var result = parseKeyValueString(str);
    var blockNames = Object.keys(result);
    var uiContext = c.getSubject().getUIContext();
    var data = uiContext.getData();
    var s = c.getSubject();
    var pos = c.getPlayer().getPosition();
    var last = uiContext.getLast();
    var player = c.getPlayer();
    var sd = {"Земля": "minecraft:dirt", "Камень": "minecraft:stone", "Песок": "minecraft:sand", "Гравий": "minecraft:gravel", "Блок режиссера": "blockbuster:director", "Gigaxaxa": "minecraft:wool"}
    
    if (last === "strings")
    {
        var selectedDisplayName = data.getString("strings");
        var values = uiContext.get("strings").getValues();
        var blockCode = result[selectedDisplayName] || "minecraft:stone";
        var new_morph = mappet.createMorph("{Name:\"item\",Stack:{id:\"" + blockCode +"\",Count:1b,Damage:0s}}");
        uiContext.get("fruit").label(data.getString("strings")).visible(true);
        uiContext.get("char").morph(new_morph);
        s.playSound("minecraft:ui.button.click", pos.x, pos.y, pos.z, 1, 2);
    
    }
    
     if (last === "take") {
        var selectedDisplayName = data.getString("strings");
        if (selectedDisplayName) {
            var blockCode = result[selectedDisplayName] || "minecraft:stone";
            var inventory = player.getInventory();
            var itemStack = mappet.createItem(blockCode);
            player.giveItem(itemStack);
            s.closeUI();
            s.playSound("minecraft:ui.button.click", pos.x, pos.y, pos.z, 1, 2);
            deleteKeyAndUpdateState(c, selectedDisplayName);
            var updatedStateString = states.getString("state_1");
            var updatedResult = parseKeyValueString(updatedStateString);
            var updatedDisplayNames = Object.keys(updatedResult);
        }
    }
    
}https://mchorse.github.io/mappet/mchorse/mappet/client/gui/utils/graphics/Graphic.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/logs/IMappetLogger.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/mappet/IMappetSchematic.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/mappet/IMappetStates.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/mappet/IMappetUIBuilder.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/mappet/IMappetUIContext.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/nbt/INBT.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/nbt/INBTCompound.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/nbt/INBTList.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/blocks/IScriptBlockState.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/entities/IScriptEntity.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/entities/IScriptEntityItem.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/IScriptEvent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/IScriptFactory.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/items/IScriptInventory.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/items/IScriptItem.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/items/IScriptItemStack.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/entities/IScriptNpc.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/entities/IScriptPlayer.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/IScriptRayTrace.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/IScriptServer.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/blocks/IScriptTileEntity.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/IScriptWorld.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/data/ScriptBox.html
https://mchorse.github.io/mappet/mchorse/mappet/api/scripts/user/data/ScriptVector.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIStringListComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIClickComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIGraphicsComponent.html
https://mchorse.github.io/mappet/index-all.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIIconButtonComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UILabelBaseComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UILabelComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UILayoutComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIMorphComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIParentComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIStackComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UITextareaComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UITextboxComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UITextComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UIToggleComponent.html
https://mchorse.github.io/mappet/mchorse/mappet/api/ui/components/UITrackpadComponent.html

короче вот ссылка с информацией и код выше мне надо так исправить чтобы код удалял из списка и переспавнивал нпс