Attempt at a shared modlist implementation - should allow visibility between liteloader and fml for "mod list display"
This commit is contained in:
parent
dc72bfe56a
commit
05c66728e7
7 changed files with 87 additions and 2 deletions
|
@ -39,6 +39,7 @@ import net.minecraft.crash.CrashReport;
|
|||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet;
|
||||
|
@ -49,6 +50,7 @@ import net.minecraft.world.World;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.MapDifference;
|
||||
import com.google.common.collect.MapDifference.ValueDifference;
|
||||
import com.google.common.collect.Maps;
|
||||
|
@ -206,6 +208,22 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String,Map<String,String>> sharedModList = (Map<String, Map<String, String>>) Launch.blackboard.get("modList");
|
||||
if (sharedModList == null)
|
||||
{
|
||||
sharedModList = Maps.newHashMap();
|
||||
Launch.blackboard.put("modList", sharedModList);
|
||||
}
|
||||
for (ModContainer mc : Loader.instance().getActiveModList())
|
||||
{
|
||||
Map<String,String> sharedModDescriptor = mc.getSharedModDescriptor();
|
||||
if (sharedModDescriptor != null)
|
||||
{
|
||||
String sharedModId = "fml:"+mc.getModId();
|
||||
sharedModList.put(sharedModId, sharedModDescriptor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,6 +267,31 @@ public class FMLClientHandler implements IFMLSidedHandler
|
|||
KeyBindingRegistry.instance().uploadKeyBindingsToGame(client.field_71474_y);
|
||||
}
|
||||
|
||||
public void extendModList()
|
||||
{
|
||||
Map<String,Map<String,String>> modList = (Map<String, Map<String, String>>) Launch.blackboard.get("modList");
|
||||
if (modList != null)
|
||||
{
|
||||
for (Entry<String, Map<String, String>> modEntry : modList.entrySet())
|
||||
{
|
||||
String sharedModId = modEntry.getKey();
|
||||
String system = sharedModId.split(":")[0];
|
||||
if ("fml".equals(system))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Map<String, String> mod = modEntry.getValue();
|
||||
String modSystem = mod.get("modsystem"); // the modsystem (FML uses FML or ModLoader)
|
||||
String modId = mod.get("id"); // unique ID
|
||||
String modVersion = mod.get("version"); // version
|
||||
String modName = mod.get("name"); // a human readable name
|
||||
String modURL = mod.get("url"); // a URL for the mod (can be empty string)
|
||||
String modAuthors = mod.get("authors"); // a csv of authors (can be empty string)
|
||||
String modDescription = mod.get("description"); // a (potentially) multiline description (can be empty string)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public void onInitializationComplete()
|
||||
{
|
||||
if (wrongMC != null)
|
||||
|
|
|
@ -180,4 +180,10 @@ public class DummyModContainer implements ModContainer
|
|||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getSharedModDescriptor()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.common.collect.Iterators;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.SetMultimap;
|
||||
import com.google.common.collect.Sets;
|
||||
|
@ -613,4 +614,17 @@ public class FMLModContainer implements ModContainer
|
|||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public Map<String, String> getSharedModDescriptor()
|
||||
{
|
||||
Map<String,String> descriptor = Maps.newHashMap();
|
||||
descriptor.put("modsystem", "FML");
|
||||
descriptor.put("id", getModId());
|
||||
descriptor.put("version",getDisplayVersion());
|
||||
descriptor.put("name", getName());
|
||||
descriptor.put("url", modMetadata.url);
|
||||
descriptor.put("authors", modMetadata.getAuthorList());
|
||||
descriptor.put("description", modMetadata.description);
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -167,4 +167,10 @@ public class InjectedModContainer implements ModContainer
|
|||
{
|
||||
return wrappedContainer.getCustomResourcePackClass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getSharedModDescriptor()
|
||||
{
|
||||
return wrappedContainer.getSharedModDescriptor();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,4 +138,6 @@ public interface ModContainer
|
|||
Map<String,String> getCustomModProperties();
|
||||
|
||||
public Class<?> getCustomResourcePackClass();
|
||||
|
||||
Map<String, String> getSharedModDescriptor();
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ModMetadata
|
|||
|
||||
public String modId;
|
||||
public String name;
|
||||
public String description;
|
||||
public String description = "";
|
||||
|
||||
public String url = "";
|
||||
public String updateUrl = "";
|
||||
|
|
|
@ -34,6 +34,7 @@ import com.google.common.base.Strings;
|
|||
import com.google.common.base.Throwables;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
|
@ -627,4 +628,17 @@ public class ModLoaderModContainer implements ModContainer
|
|||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Map<String, String> getSharedModDescriptor()
|
||||
{
|
||||
Map<String,String> descriptor = Maps.newHashMap();
|
||||
descriptor.put("modsystem", "ModLoader");
|
||||
descriptor.put("id", getModId());
|
||||
descriptor.put("version",getDisplayVersion());
|
||||
descriptor.put("name", getName());
|
||||
descriptor.put("url", metadata.url);
|
||||
descriptor.put("authors", metadata.getAuthorList());
|
||||
descriptor.put("description", metadata.description);
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue