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

system.runInterval(() => {
    let itemEntities = world.getDimension(MinecraftDimensionTypes.overworld).getEntities({ type: "minecraft:item" })
    itemEntities.forEach(itemEntity => {
        let item = itemEntity.getComponent(EntityItemComponent.componentId).itemStack
        const itemIdFilter = ["netherite", "darksteel", "cursed", "warden_", "shadow", "void", "claymore", "wither_shard", "crown", "fiery:totem", "hero_", "spear_of", "dragon_pearl", "steel", "sword_of_fear"];
        let itemID = item.typeId
        if (itemIdFilter.some((filter) => itemID.includes(filter)) && !itemEntity.hasTag("fire_immune")) {
            itemEntity.runCommand(`tag @s add fire_immune`);
        } else { }
    });
});