package com.khorn.terraincontrol.bukkit.generator.structures;

import com.khorn.terraincontrol.LocalBiome;
import com.khorn.terraincontrol.bukkit.BukkitBiome;
import com.khorn.terraincontrol.configuration.BiomeConfig.RareBuildingType;
import com.khorn.terraincontrol.configuration.WorldSettings;
import com.khorn.terraincontrol.util.minecraftTypes.StructureNames;
import net.minecraft.server.v1_8_R3.*;
import net.minecraft.server.v1_8_R3.BiomeBase.BiomeMeta;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RareBuildingGen extends StructureGenerator
{
    public List<BiomeBase> biomeList;

    /**
     * contains possible spawns for scattered features
     */
    @SuppressWarnings("rawtypes")
    private List scatteredFeatureSpawnList;

    /**
     * the maximum distance between scattered features
     */
    private int maxDistanceBetweenScatteredFeatures;

    /**
     * the minimum distance between scattered features
     */
    private int minDistanceBetweenScatteredFeatures;

    @SuppressWarnings({"unchecked", "rawtypes"})
    public RareBuildingGen(WorldSettings configs)
    {
        biomeList = new ArrayList<BiomeBase>();

        for (LocalBiome biome : configs.biomes)
        {
            if (biome == null)
                continue;
            if (biome.getBiomeConfig().rareBuildingType != RareBuildingType.disabled)
            {
                biomeList.add(((BukkitBiome) biome).getHandle());
            }
        }

        this.scatteredFeatureSpawnList = new ArrayList();
        this.maxDistanceBetweenScatteredFeatures = configs.worldConfig.maximumDistanceBetweenRareBuildings;
        // Minecraft's internal minimum distance is one chunk lower than TC's
        // value
        this.minDistanceBetweenScatteredFeatures = configs.worldConfig.minimumDistanceBetweenRareBuildings - 1;
        this.scatteredFeatureSpawnList.add(new BiomeMeta(EntityWitch.class, 1, 1, 1));
    }

    @Override
    // canSpawnStructureAtChunkCoords
    protected boolean a(int chunkX, int chunkZ)
    {
        int var3 = chunkX;
        int var4 = chunkZ;

        if (chunkX < 0)
        {
            chunkX -= this.maxDistanceBetweenScatteredFeatures - 1;
        }

        if (chunkZ < 0)
        {
            chunkZ -= this.maxDistanceBetweenScatteredFeatures - 1;
        }

        int var5 = chunkX / this.maxDistanceBetweenScatteredFeatures;
        int var6 = chunkZ / this.maxDistanceBetweenScatteredFeatures;
        Random random = this.c.a(var5, var6, 14357617);
        var5 *= this.maxDistanceBetweenScatteredFeatures;
        var6 *= this.maxDistanceBetweenScatteredFeatures;
        var5 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures);
        var6 += random.nextInt(this.maxDistanceBetweenScatteredFeatures - this.minDistanceBetweenScatteredFeatures);

        if (var3 == var5 && var4 == var6)
        {
            BiomeBase biomeAtPosition = this.c.getWorldChunkManager().getBiome(new BlockPosition(var3 * 16 + 8, 0, var4 * 16 + 8));

            for (BiomeBase biome : biomeList)
            {
                if (biomeAtPosition.equals(biome))
                {
                    return true;
                }
            }
        }

        return false;
    }

    @Override
    // getStructureStart
    protected StructureStart b(int chunkX, int chunkZ)
    {
        return new RareBuildingStart(this.c, this.b, chunkX, chunkZ);
    }

    /**
     * returns possible spawns for scattered features
     */
    @SuppressWarnings({"rawtypes", "UnusedDeclaration"})
    public List getScatteredFeatureSpawnList()
    {
        return this.scatteredFeatureSpawnList;
    }

    @Override
    public String a()
    {
        return StructureNames.RARE_BUILDING;
    }
}

@@ -393,17 +393,25 @@
 v1_8_R3.
-*
+BiomeBase
 ;%0Aimport
@@ -445,26 +445,128 @@
 R3.B
-iomeBase.BiomeMeta
+lockPosition;%0Aimport net.minecraft.server.v1_8_R3.StructureGenerator;%0Aimport net.minecraft.server.v1_8_R3.StructureStart
 ;%0A%0Ai
@@ -742,158 +742,8 @@
 t;%0A%0A
-    /**%0A     * contains possible spawns for scattered features%0A     */%0A    @SuppressWarnings(%22rawtypes%22)%0A    private List scatteredFeatureSpawnList;%0A%0A
     
@@ -992,57 +992,8 @@
 s;%0A%0A
-    @SuppressWarnings(%7B%22unchecked%22, %22rawtypes%22%7D)%0A
     
@@ -1403,66 +1403,8 @@
  %7D%0A%0A
-        this.scatteredFeatureSpawnList = new ArrayList();%0A
     
@@ -1718,95 +1718,8 @@
  1;%0A
-        this.scatteredFeatureSpawnList.add(new BiomeMeta(EntityWitch.class, 1, 1, 1));%0A
     
@@ -3166,32 +3166,32 @@
 t chunkZ)%0A    %7B%0A
+
         return n
@@ -3255,242 +3255,8 @@
  %7D%0A%0A
-    /**%0A     * returns possible spawns for scattered features%0A     */%0A    @SuppressWarnings(%7B%22rawtypes%22, %22UnusedDeclaration%22%7D)%0A    public List getScatteredFeatureSpawnList()%0A    %7B%0A        return this.scatteredFeatureSpawnList;%0A    %7D%0A%0A
     

Remove unused code in RareBuildingGen