print("§a[Alpha World Tweaker] Ajustando biomas, estruturas e cavernas...")

allBiomes = forAllBiomes()
overworldKeep = ["minecraft:plains", "minecraft:forest"]

function isOverworldBiome(id) {
    return !(id.startsWith("minecraft:nether") || id.startsWith("minecraft:end"))
}

function isNetherBiome(id) {
    return id.startsWith("minecraft:nether")
}

// Percentual de spawn Overworld
overworldSpawnWeights = {
    "minecraft:plains": 70,
    "minecraft:forest": 30
}

for each biome in allBiomes:
    id = biome.getRegistryName()
    
    // Overworld
    if isOverworldBiome(id):
        if !(overworldKeep contains id):
            biome.set("isSpawnBiome", false)
            biome.set("genWeight", 0)
            biome.removeAllSpawns()
            biome.removeDecoration("ALL")
            biome.removeFeature("ALL")   // remove tudo
            biome.set("temperature", 0.0)
            biome.set("precipitation", "none")
            biome.set("category", "none")
            print("§cRemovido Overworld: " + id)
        else:
            // Mantém spawn e peso
            biome.set("genWeight", overworldSpawnWeights[id])
            
            // Reduz árvores e decorações para estilo Alpha
            biome.removeFeature("ALL_TREE")
            biome.addFeature("minecraft:tree")
            biome.set("treeDensity", 0.2)
            biome.set("grassDensity", 0.1)
            biome.set("flowerDensity", 0.05)
            
            // Estruturas: mantém apenas vilas
            biome.removeFeature("ALL_STRUCTURE")
            biome.addFeature("minecraft:village")
            
            print("§bMantido Overworld: " + id + " (peso: " + overworldSpawnWeights[id] + ") - estilo Alpha + vilas")

// Nether
    if isNetherBiome(id):
        oldWeight = biome.get("genWeight")
        biome.set("genWeight", Math.floor(oldWeight / 5))  // reduz a frequência em 80%
        print("§eNether raro: " + id + " (peso antigo: " + oldWeight + ")")

// Cavernas
caves = forAllBiomes("minecraft:cave")
for each cave in caves:
    cave.set("genWeight", 50)       // ajusta spawn de cavernas
    print("§dBioma de caverna ajustado: " + cave.getRegistryName())
