mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-18 19:39:22 +00:00
API is now able to "provide" and "own" itself. Useful for libraries without a Mod in them.
To go along with this, you can now require an API, with a version, in your mod dependency string
This commit is contained in:
1 parent
be45501749
commit
71a9586fbb
2 files changed
+21
-3
No files matched your search
@@ -38,6 +38,7 @@ import com.google.common.collect.HashBiMap;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableMultiset;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
@@ -199,7 +200,7 @@ public class Loader
|
||||
try
|
||||
{
|
||||
BiMap<String, ArtifactVersion> modVersions = HashBiMap.create();
|
||||
for (ModContainer mod : getActiveModList())
|
||||
for (ModContainer mod : Iterables.concat(getActiveModList(), ModAPIManager.INSTANCE.getAPIList()))
|
||||
{
|
||||
modVersions.put(mod.getModId(), mod.getProcessedVersion());
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ModAPIManager {
|
||||
private String version;
|
||||
private Set<String> currentReferents;
|
||||
private Set<String> packages;
|
||||
private boolean selfReferenced;
|
||||
|
||||
public APIContainer(String providedAPI, String apiVersion, File source, ArtifactVersion ownerMod)
|
||||
{
|
||||
@@ -67,7 +68,7 @@ public class ModAPIManager {
|
||||
@Override
|
||||
public String getModId()
|
||||
{
|
||||
return "API:"+providedAPI;
|
||||
return providedAPI;
|
||||
}
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependants()
|
||||
@@ -78,7 +79,7 @@ public class ModAPIManager {
|
||||
@Override
|
||||
public List<ArtifactVersion> getDependencies()
|
||||
{
|
||||
return ImmutableList.of(ownerMod);
|
||||
return selfReferenced ? ImmutableList.<ArtifactVersion>of() : ImmutableList.of(ownerMod);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,6 +119,11 @@ public class ModAPIManager {
|
||||
addAPIReference(modId);
|
||||
}
|
||||
}
|
||||
|
||||
void markSelfReferenced()
|
||||
{
|
||||
selfReferenced = true;
|
||||
}
|
||||
}
|
||||
public void registerDataTableAndParseAPI(ASMDataTable dataTable)
|
||||
{
|
||||
@@ -181,6 +187,12 @@ public class ModAPIManager {
|
||||
do
|
||||
{
|
||||
APIContainer parent = apiContainers.get(owner.getLabel());
|
||||
if (parent == container)
|
||||
{
|
||||
FMLLog.finer("APIContainer %s is it's own parent. skipping", owner);
|
||||
container.markSelfReferenced();
|
||||
break;
|
||||
}
|
||||
FMLLog.finer("Removing upstream parent %s from %s", parent.ownerMod.getLabel(), container);
|
||||
container.currentReferents.remove(parent.ownerMod.getLabel());
|
||||
container.referredMods.remove(parent.ownerMod);
|
||||
@@ -213,4 +225,9 @@ public class ModAPIManager {
|
||||
{
|
||||
return apiContainers.containsKey(modId);
|
||||
}
|
||||
|
||||
public Iterable<? extends ModContainer> getAPIList()
|
||||
{
|
||||
return apiContainers.values();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user