    001    package net.minecraftforge.common;
    002
    003    import java.io.File;
    004    import java.util.Arrays;
    005    import java.util.Map;
    006
    007    import net.minecraft.src.NBTBase;
    008    import net.minecraft.src.NBTTagCompound;
    009    import net.minecraft.src.SaveHandler;
    010    import net.minecraft.src.WorldInfo;
    011
    012    import com.google.common.eventbus.EventBus;
    013    import com.google.common.eventbus.Subscribe;
    014
    015    import cpw.mods.fml.common.DummyModContainer;
    016    import cpw.mods.fml.common.LoadController;
    017    import cpw.mods.fml.common.Loader;
    018    import cpw.mods.fml.common.ModMetadata;
    019    import cpw.mods.fml.common.WorldAccessContainer;
    020    import cpw.mods.fml.common.event.FMLPostInitializationEvent;
    021    import cpw.mods.fml.common.event.FMLPreInitializationEvent;
    022
    023    import static net.minecraftforge.common.ForgeVersion.*;
    024
    025    public class ForgeDummyContainer extends DummyModContainer implements WorldAccessContainer
    026    {
    027        public ForgeDummyContainer()
    028        {
    029            super(new ModMetadata());
    030            ModMetadata meta = getMetadata();
    031            meta.modId       = "Forge";
    032            meta.name        = "Minecraft Forge";
    033            meta.version     = String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion);
    034            meta.credits     = "Made possible with help from many people";
    035            meta.authorList  = Arrays.asList("LexManos", "Eloraam", "Spacetoad");
    036            meta.description = "Minecraft Forge is a common open source API allowing a broad range of mods " +
    037                               "to work cooperatively together. It allows many mods to be created without " +
    038                               "them editing the main Minecraft code.";
    039            meta.url         = "http://MinecraftForge.net";
    040            meta.updateUrl   = "http://MinecraftForge.net/forum/index.php/topic,5.0.html";
    041            meta.screenshots = new String[0];
    042            meta.logoFile    = "/forge_logo.png";
    043
    044            Configuration config = new Configuration(new File(Loader.instance().getConfigDir(), "forge.cfg"));
    045            if (!config.isChild)
    046            {
    047                config.load();
    048                Property enableGlobalCfg = config.get(Configuration.CATEGORY_GENERAL, "enableGlobalConfig", false);
    049                if (enableGlobalCfg.getBoolean(false))
    050                {
    051                    Configuration.enableGlobalConfig();
    052                }
    053                config.save();
    054            }
    055        }
    056
    057        @Override
    058        public boolean registerBus(EventBus bus, LoadController controller)
    059        {
    060            bus.register(this);
    061            return true;
    062        }
    063
    064        @Subscribe
    065        public void preInit(FMLPreInitializationEvent evt)
    066        {
    067            ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
    068        }
    069
    070        @Subscribe
    071        public void postInit(FMLPostInitializationEvent evt)
    072        {
    073            ForgeChunkManager.loadConfiguration();
    074        }
    075
    076        @Override
    077        public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info)
    078        {
    079            NBTTagCompound forgeData = new NBTTagCompound();
    080            NBTTagCompound dimData = DimensionManager.saveDimensionDataMap();
    081            forgeData.setCompoundTag("DimensionData", dimData);
    082            return forgeData;
    083        }
    084
    085        @Override
    086        public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag)
    087        {
    088            if (tag.hasKey("DimensionData"))
    089            {
    090                DimensionManager.loadDimensionDataMap(tag.hasKey("DimensionData") ? tag.getCompoundTag("DimensionData") : null);
    091            }
    092        }
    093    }