package com.zivilon.cinder_loe.world;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import lotr.common.*;
import lotr.common.world.LOTRWorldChunkManager;
import lotr.common.world.LOTRWorldProvider;
import net.minecraft.util.StatCollector;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.client.IRenderHandler;

public abstract class CinderWorldProvider extends LOTRWorldProvider {
    public static int MOON_PHASES = 8;
    @SideOnly(value= Side.CLIENT)
    private IRenderHandler lotrSkyRenderer;
    @SideOnly(value=Side.CLIENT)
    private IRenderHandler lotrCloudRenderer;
    @SideOnly(value=Side.CLIENT)
    private IRenderHandler lotrWeatherRenderer;
    private boolean spawnHostiles = true;
    private boolean spawnPeacefuls = true;
    private double cloudsR;
    private double cloudsG;
    private double cloudsB;
    private double fogR;
    private double fogG;
    private double fogB;

    public abstract LOTRDimension getLOTRDimension();

    public void registerWorldChunkManager() {
        this.worldChunkMgr = new LOTRWorldChunkManager(this.worldObj, this.getLOTRDimension());
        this.dimensionId = this.getLOTRDimension().dimensionID;
    }

    public String getWelcomeMessage() {
        return StatCollector.translateToLocalFormatted((String)"lotr.dimension.enter", (Object[])new Object[]{this.getLOTRDimension().getDimensionName()});
    }

    public String getDepartMessage() {
        return StatCollector.translateToLocalFormatted((String)"lotr.dimension.exit", (Object[])new Object[]{this.getLOTRDimension().getDimensionName()});
    }

    public String getSaveFolder() {
        return this.getLOTRDimension().dimensionName;
    }

    public String getDimensionName() {
        return this.getLOTRDimension().dimensionName;
    }

    public boolean canRespawnHere() {
        return false;
    }

    public BiomeGenBase getBiomeGenForCoords(int i, int k) {
        Chunk chunk;
        if (this.worldObj.blockExists(i, 0, k) && (chunk = this.worldObj.getChunkFromBlockCoords(i, k)) != null) {
            int chunkX = i & 0xF;
            int chunkZ = k & 0xF;
            int biomeID = chunk.getBiomeArray()[chunkZ << 4 | chunkX] & 0xFF;
            if (biomeID == 255) {
                BiomeGenBase biomegenbase = this.worldChunkMgr.getBiomeGenAt((chunk.xPosition << 4) + chunkX, (chunk.zPosition << 4) + chunkZ);
                biomeID = biomegenbase.biomeID;
                chunk.getBiomeArray()[chunkZ << 4 | chunkX] = (byte)(biomeID & 0xFF);
            }
            LOTRDimension dim = this.getLOTRDimension();
            return dim.biomeList[biomeID] == null ? dim.biomeList[0] : dim.biomeList[biomeID];
        }
        return this.worldChunkMgr.getBiomeGenAt(i, k);
    }


}
