001 /* 002 * The FML Forge Mod Loader suite. 003 * Copyright (C) 2012 cpw 004 * 005 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free 006 * Software Foundation; either version 2.1 of the License, or any later version. 007 * 008 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 009 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 010 * 011 * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 012 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 013 */ 014 015 package cpw.mods.fml.common; 016 017 import java.util.Arrays; 018 import java.util.Map; 019 import java.util.Set; 020 import java.util.concurrent.ConcurrentMap; 021 022 import net.minecraft.src.NBTBase; 023 import net.minecraft.src.NBTTagCompound; 024 import net.minecraft.src.NBTTagList; 025 import net.minecraft.src.NBTTagString; 026 import net.minecraft.src.SaveHandler; 027 import net.minecraft.src.WorldInfo; 028 029 import com.google.common.collect.MapMaker; 030 import com.google.common.collect.Sets; 031 import com.google.common.eventbus.EventBus; 032 033 /** 034 * @author cpw 035 * 036 */ 037 public class FMLDummyContainer extends DummyModContainer implements WorldAccessContainer 038 { 039 public FMLDummyContainer() 040 { 041 super(new ModMetadata()); 042 ModMetadata meta = getMetadata(); 043 meta.modId="FML"; 044 meta.name="Forge Mod Loader"; 045 meta.version=Loader.instance().getFMLVersionString(); 046 meta.credits="Made possible with help from many people"; 047 meta.authorList=Arrays.asList("cpw, LexManos"); 048 meta.description="The Forge Mod Loader provides the ability for systems to load mods " + 049 "from the file system. It also provides key capabilities for mods to be able " + 050 "to cooperate and provide a good modding environment. " + 051 "The mod loading system is compatible with ModLoader, all your ModLoader " + 052 "mods should work."; 053 meta.url="https://github.com/cpw/FML/wiki"; 054 meta.updateUrl="https://github.com/cpw/FML/wiki"; 055 meta.screenshots=new String[0]; 056 meta.logoFile=""; 057 } 058 059 @Override 060 public boolean registerBus(EventBus bus, LoadController controller) 061 { 062 return true; 063 } 064 065 @Override 066 public NBTTagCompound getDataForWriting(SaveHandler handler, WorldInfo info) 067 { 068 NBTTagCompound fmlData = new NBTTagCompound(); 069 NBTTagList list = new NBTTagList(); 070 for (ModContainer mc : Loader.instance().getActiveModList()) 071 { 072 NBTTagCompound mod = new NBTTagCompound(); 073 mod.setString("ModId", mc.getModId()); 074 mod.setString("ModVersion", mc.getVersion()); 075 list.appendTag(mod); 076 } 077 fmlData.setTag("ModList", list); 078 return fmlData; 079 } 080 081 @Override 082 public void readData(SaveHandler handler, WorldInfo info, Map<String, NBTBase> propertyMap, NBTTagCompound tag) 083 { 084 if (tag.hasKey("ModList")) 085 { 086 NBTTagList modList = tag.getTagList("ModList"); 087 for (int i = 0; i < modList.tagCount(); i++) 088 { 089 NBTTagCompound mod = (NBTTagCompound) modList.tagAt(i); 090 String modId = mod.getString("ModId"); 091 String modVersion = mod.getString("ModVersion"); 092 ModContainer container = Loader.instance().getIndexedModList().get(modId); 093 if (container == null) 094 { 095 FMLLog.severe("This world was saved with mod %s which appears to be missing, things may not work well", modId); 096 continue; 097 } 098 if (!modVersion.equals(container.getVersion())) 099 { 100 FMLLog.info("This world was saved with mod %s version %s and it is now at version %s, things may not work well", modId, modVersion, container.getVersion()); 101 } 102 } 103 } 104 } 105 }