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