Package com.khorn.terraincontrol.forge

Source Code of com.khorn.terraincontrol.forge.ForgeBiome

package com.khorn.terraincontrol.forge;

import com.khorn.terraincontrol.BiomeIds;
import com.khorn.terraincontrol.LocalBiome;
import com.khorn.terraincontrol.configuration.BiomeConfig;
import com.khorn.terraincontrol.forge.generator.BiomeGenCustom;
import net.minecraft.world.biome.BiomeGenBase;

public class ForgeBiome implements LocalBiome
{
    private final BiomeGenCustom biomeBase;
    private final BiomeIds biomeIds;
    private final BiomeConfig biomeConfig;

    /**
     * Creates a new biome with the given name and id. Also registers it in
     * Minecraft's biome array, but only when the biome is not virtual.
     *
     * @param biomeConfig The config of the biome.
     * @param biomeIds    The ids of the biome.
     * @return The registered biome.
     */
    public static ForgeBiome createBiome(BiomeConfig biomeConfig, BiomeIds biomeIds)
    {
        // Store the previous biome in a variable
        BiomeGenBase previousBiome = BiomeGenBase.getBiome(biomeIds.getSavedId());

        // Register new biome
        ForgeBiome biome = new ForgeBiome(biomeConfig, new BiomeGenCustom(biomeConfig.getName(), biomeIds));

        // Restore settings of the previous biome
        if (previousBiome != null)
        {
            biome.biomeBase.copyBiome(previousBiome);
        }

        return biome;
    }

    private ForgeBiome(BiomeConfig biomeConfig, BiomeGenCustom biome)
    {
        this.biomeBase = biome;
        this.biomeIds = new BiomeIds(biome.generationId, biome.biomeID);
        this.biomeConfig = biomeConfig;
    }

    @Override
    public boolean isCustom()
    {
        return true;
    }

    @Override
    public void setEffects()
    {
        biomeBase.setEffects(biomeConfig);
    }

    @Override
    public String getName()
    {
        return biomeBase.biomeName;
    }

    public BiomeGenCustom getHandle()
    {
        return biomeBase;
    }

    @Override
    public BiomeIds getIds()
    {
        return biomeIds;
    }

    @Override
    public float getTemperatureAt(int x, int y, int z)
    {
        return biomeBase.getFloatTemperature(x, y, z);
    }

    @Override
    public BiomeConfig getBiomeConfig()
    {
        return biomeConfig;
    }
   
    @Override
    public String toString()
    {
        return getName() + "[" + biomeIds + "]";
    }
}
TOP

Related Classes of com.khorn.terraincontrol.forge.ForgeBiome

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.