import { world, system, ItemStack } from '@minecraft/server'

system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        //list of items
        const Items = [
            "minecraft:acacia_door",
            "minecraft:anvil",
            "minecraft:armor_stand",
            "minecraft:arrow",
            "minecraft:axolotl_spawn_egg",
            "minecraft:barrier",
            "minecraft:beacon",
            "minecraft:bed",
            "minecraft:bedrock",
            "minecraft:beetroot_seeds",
            "minecraft:bell",
            "minecraft:birch_sign",
            "minecraft:blaze_rod",
            "minecraft:blaze_spawn_egg",
            "minecraft:blue_ice",
            "minecraft:breeze_rod",
            "minecraft:bone",
            "minecraft:bone_block",
            "minecraft:bone_meal",
            "minecraft:bow",
            "minecraft:bowl",
            "minecraft:brewing_stand",
            "minecraft:bucket",
            "minecraft:cactus",
            "minecraft:cake",
            "minecraft:campfire",
            "minecraft:candle",
            "minecraft:carrot",
            "minecraft:carved_pumpkin",
            "minecraft:cauldron",
            "minecraft:coal_block",
            "minecraft:cobblestone",
            "minecraft:cooked_beef",
            "minecraft:cooked_cod",
            "minecraft:command_block",
            "minecraft:conduit",
            "minecraft:cow_spawn_egg",
            "minecraft:creeper_spawn_egg",
            "minecraft:crossbow",
            "minecraft:deadbush",
            "minecraft:diamond_block",
            "minecraft:dragon_breath",
            "minecraft:dragon_egg",
            "minecraft:dried_kelp",
            "minecraft:dried_kelp_block",
            "minecraft:egg",
            "minecraft:elytra",
            "minecraft:emerald_block",
            "minecraft:empty_map",
            "minecraft:enchanted_book",
            "minecraft:enchanted_golden_apple",
            "minecraft:enchanting_table",
            "minecraft:end_crystal",
            "minecraft:ender_pearl",
            "minecraft:end_portal_frame",
            "minecraft:end_rod",
            "minecraft:experience_bottle",
            "minecraft:fire_charge",
            "minecraft:firework_rocket",
            "minecraft:fishing_rod",
            "minecraft:flint",
            "minecraft:frame",
            "minecraft:ghast_tear",
            "minecraft:glass",
            "minecraft:glass_bottle",
            "minecraft:glow_ink_sac",
            "minecraft:glowstone",
            "minecraft:gold_block",
            "minecraft:golden_apple",
            "minecraft:grass",
            "minecraft:grass_path",
            "minecraft:gunpowder",
            "minecraft:heavy_core",
            "minecraft:hopper",
            "minecraft:iron_block",
            "minecraft:iron_boots",
            "minecraft:iron_chestplate",
            "minecraft:iron_helmet",
            "minecraft:iron_leggings",
            "minecraft:lava_bucket",
            "minecraft:lead",
            "minecraft:leaves",
            "minecraft:leaves2",
            "minecraft:log",
            "minecraft:melon_block",
            "minecraft:milk_bucket",
            "minecraft:mob_spawner",
            "minecraft:mooshroom_spawn_egg",
            "minecraft:music_disc_5",
            "minecraft:music_disc_11",
            "minecraft:music_disc_blocks",
            "minecraft:music_disc_cat",
            "minecraft:music_disc_chirp",
            "minecraft:music_disc_creator",
            "minecraft:music_disc_creator_music_box",
            "minecraft:music_disc_far",
            "minecraft:music_disc_mall",
            "minecraft:music_disc_mellohi",
            "minecraft:music_disc_otherside",
            "minecraft:music_disc_pigstep",
            "minecraft:music_disc_precipice",
            "minecraft:music_disc_relic",
            "minecraft:music_disc_stal",
            "minecraft:music_disc_strad",
            "minecraft:music_disc_wait",
            "minecraft:music_disc_ward",
            "minecraft:name_tag",
            "minecraft:netherite_boots",
            "minecraft:netherite_chestplate",
            "minecraft:netherite_helmet",
            "minecraft:netherite_ingot",
            "minecraft:netherite_leggings",
            "minecraft:netherite_upgrade_smithing_template",
            "minecraft:nether_star",
            "minecraft:nether_wart",
            "minecraft:oak_boat",
            "minecraft:oak_sign",
            "minecraft:packed_ice",
            "minecraft:painting",
            "minecraft:poisonous_potato",
            "minecraft:potato",
            "minecraft:powder_snow_bucket",
            "minecraft:pufferfish_bucket",
            "minecraft:pumpkin",
            "minecraft:quartz",
            "minecraft:rabbit",
            "minecraft:rabbit_foot",
            "minecraft:rabbit_hide",
            "minecraft:rabbit_stew",
            "minecraft:red_flower",
            "minecraft:redstone",
            "minecraft:redstone_torch",
            "minecraft:repeater",
            "minecraft:respawn_anchor",
            "minecraft:salmon_bucket",
            "minecraft:sand",
            "minecraft:sapling",
            "minecraft:seagrass",
            "minecraft:sea_lantern",
            "minecraft:sea_pickle",
            "minecraft:shears",
            "minecraft:shulker_box",
            "minecraft:skeleton_spawn_egg",
            "minecraft:skeleton_horse_spawn_egg",
            "minecraft:snow",
            "minecraft:snowball",
            "minecraft:snow_layer",
            "minecraft:soul_torch",
            "minecraft:stick",
            "minecraft:sticky_piston",
            "minecraft:suspicious_stew",
            "minecraft:tall_grass",
            "minecraft:tnt",
            "minecraft:torch",
            "minecraft:totem_of_undying",
            "minecraft:trial_key",
            "minecraft:trident",
            "minecraft:turtle_egg",
            "minecraft:turtle_helmet",
            "minecraft:villager_spawn_egg",
            "minecraft:warden_spawn_egg",
            "minecraft:wheat_seeds",
            "minecraft:wooden_button",
            "minecraft:zombie_spawn_egg",
            "omni_science:bagel",
            "omni_science:broccoli",
            "omni_science:poop",
            "omni_science:anti_missing_texture_catalyst"
        ]

        const randomItem = Math.floor(Math.random() * Items.length)
        const item = new ItemStack(`${(randomItem, Items[randomItem])}`, 1)
        const inventory = player.getComponent("minecraft:inventory").container
        inventory.addItem(item)
    }
}, 1200)









system.runInterval(() => {
    for (let player of world.getAllPlayers()) {
        const UiElements = [
            "hotbar",
            "health",
            "hunger",
            "crosshair",
            "progress_bar"
        ]
        const randomUi = Math.floor(Math.random() * UiElements.length)
        player.runCommandAsync(`hud @s hide ${(randomUi, UiElements[randomUi])}`)
        system.runTimeout(() => {
            player.runCommandAsync(`hud @s reset`)
            HideUi(player)
        }, 100)
    }
}, 12000)
