package me.km.world;

import net.minecraft.world.World;
import net.minecraft.world.storage.WorldInfo;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.world.WorldEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;

public class WorldEvents {
    @SubscribeEvent
    public void onWorldLoad(WorldEvent.Load e) {
        World w = e.getWorld().getWorld();
        DimensionManager.keepLoaded(w.getDimension().getType(), true);
    }

    @SubscribeEvent
    public void onWorldUnload(WorldEvent.Unload e) {
        WorldInfo info = e.getWorld().getWorld().getWorldInfo();
        if(info instanceof ModWorldInfo) {
            ((ModWorldInfo) info).onSave();
        }
    }
}
