package net.minecraft.world.level.biome;

import net.minecraft.world.level.levelgen.WorldgenRandom;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.levelgen.feature.configurations.ShipwreckConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.MineshaftConfiguration;
import net.minecraft.world.level.levelgen.feature.MineshaftFeature;
import net.minecraft.world.level.levelgen.feature.configurations.OceanRuinConfiguration;
import net.minecraft.world.level.levelgen.structure.OceanRuinFeature;
import net.minecraft.world.level.levelgen.feature.Feature;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilderBaseConfiguration;
import net.minecraft.world.level.levelgen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise;

public final class FrozenOceanBiome extends Biome {
    protected static final PerlinSimplexNoise FROZEN_TEMPERATURE_NOISE;
    
    public FrozenOceanBiome() {
        super(new BiomeBuilder().<SurfaceBuilderBaseConfiguration>surfaceBuilder(SurfaceBuilder.FROZEN_OCEAN, SurfaceBuilder.CONFIG_GRASS).precipitation(Precipitation.SNOW).biomeCategory(BiomeCategory.OCEAN).depth(-1.0f).scale(0.1f).temperature(0.0f).downfall(0.5f).waterColor(3750089).waterFogColor(329011).parent(null));
        this.<OceanRuinConfiguration>addStructureStart(Feature.OCEAN_RUIN.configured(new OceanRuinConfiguration(OceanRuinFeature.Type.COLD, 0.3f, 0.9f)));
        this.<MineshaftConfiguration>addStructureStart(Feature.MINESHAFT.configured(new MineshaftConfiguration(0.004, MineshaftFeature.Type.NORMAL)));
        this.<ShipwreckConfiguration>addStructureStart(Feature.SHIPWRECK.configured(new ShipwreckConfiguration(false)));
        BiomeDefaultFeatures.addOceanCarvers(this);
        BiomeDefaultFeatures.addStructureFeaturePlacement(this);
        BiomeDefaultFeatures.addDefaultLakes(this);
        BiomeDefaultFeatures.addIcebergs(this);
        BiomeDefaultFeatures.addDefaultMonsterRoom(this);
        BiomeDefaultFeatures.addBlueIce(this);
        BiomeDefaultFeatures.addDefaultUndergroundVariety(this);
        BiomeDefaultFeatures.addDefaultOres(this);
        BiomeDefaultFeatures.addDefaultSoftDisks(this);
        BiomeDefaultFeatures.addWaterTrees(this);
        BiomeDefaultFeatures.addDefaultFlowers(this);
        BiomeDefaultFeatures.addDefaultGrass(this);
        BiomeDefaultFeatures.addDefaultMushrooms(this);
        BiomeDefaultFeatures.addDefaultExtraVegetation(this);
        BiomeDefaultFeatures.addDefaultSprings(this);
        BiomeDefaultFeatures.addSurfaceFreezing(this);
        this.addSpawn(MobCategory.WATER_CREATURE, new SpawnerData(EntityType.SQUID, 1, 1, 4));
        this.addSpawn(MobCategory.WATER_CREATURE, new SpawnerData(EntityType.SALMON, 15, 1, 5));
        this.addSpawn(MobCategory.CREATURE, new SpawnerData(EntityType.POLAR_BEAR, 1, 1, 2));
        this.addSpawn(MobCategory.AMBIENT, new SpawnerData(EntityType.BAT, 10, 8, 8));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.SPIDER, 100, 4, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.ZOMBIE, 95, 4, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.DROWNED, 5, 1, 1));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.ZOMBIE_VILLAGER, 5, 1, 1));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.SKELETON, 100, 4, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.CREEPER, 100, 4, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.SLIME, 100, 4, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.ENDERMAN, 10, 1, 4));
        this.addSpawn(MobCategory.MONSTER, new SpawnerData(EntityType.WITCH, 5, 1, 1));
    }
    
    @Override
    protected float getTemperatureNoCache(final BlockPos fk) {
        float float3 = this.getTemperature();
        final double double4 = FrozenOceanBiome.FROZEN_TEMPERATURE_NOISE.getValue(fk.getX() * 0.05, fk.getZ() * 0.05, false) * 7.0;
        final double double5 = FrozenOceanBiome.BIOME_INFO_NOISE.getValue(fk.getX() * 0.2, fk.getZ() * 0.2, false);
        final double double6 = double4 + double5;
        if (double6 < 0.3) {
            final double double7 = FrozenOceanBiome.BIOME_INFO_NOISE.getValue(fk.getX() * 0.09, fk.getZ() * 0.09, false);
            if (double7 < 0.8) {
                float3 = 0.2f;
            }
        }
        if (fk.getY() > 64) {
            final float float4 = (float)(FrozenOceanBiome.TEMPERATURE_NOISE.getValue(fk.getX() / 8.0f, fk.getZ() / 8.0f, false) * 4.0);
            return float3 - (float4 + fk.getY() - 64.0f) * 0.05f / 30.0f;
        }
        return float3;
    }
    
    static {
        FROZEN_TEMPERATURE_NOISE = new PerlinSimplexNoise(new WorldgenRandom(3456L), 2, 0);
    }
}
