package me.km.world;

import me.km.utils.ReflectionUtils;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.OverworldDimension;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import org.apache.logging.log4j.LogManager;

public class ModOverworldDimension extends OverworldDimension
{
    public ModOverworldDimension(World worldIn, DimensionType typeIn)
    {
        super(worldIn, typeIn);
    }

    @Override
    public ChunkGenerator<? extends GenerationSettings> createChunkGenerator()
    {
        LogManager.getLogger().warn("Try swapping " + world + " " + world.getDimension().getType());
        
        if(world.getDimension().getType().isVanilla())
        {
            LogManager.getLogger().warn("no swap in vanilla world");
            return super.createChunkGenerator();
        }
        
        ReflectionUtils.setWorldInfo(world, new ModWorldInfo(world.getWorldInfo(), WorldManager.getName(world), world.getServer()));
        
        return super.createChunkGenerator();
    }
}
