More tests. Substitutions now work, and a fix is included. *sigh* Closes too many bugs to count.

This commit is contained in:
cpw committed 2016-07-20 16:03:56 -04:00
1 parent 22394f87d5
commit 7d4bf619fe
6 files changed
+123 -5

No files matched your search

@@ -199,6 +199,10 @@ public class LoadController
return activeContainer != null ? activeContainer : findActiveContainerFromStack();
}
void forceActiveContainer(ModContainer container)
{
activeContainer = container;
}
@Subscribe
public void propogateStateMessage(FMLEvent stateEvent)
{
@@ -38,6 +38,7 @@ import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.fml.common.LoaderState.ModState;
import net.minecraftforge.fml.common.ModContainer.Disableable;
import net.minecraftforge.fml.common.ProgressManager.ProgressBar;
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import net.minecraftforge.fml.common.discovery.ModDiscoverer;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLLoadEvent;
@@ -488,11 +489,24 @@ public class Loader
return instance().mods != null ? ImmutableList.copyOf(instance().mods) : ImmutableList.<ModContainer>of();
}
/**
* Used to setup a testharness with a single dummy mod instance for use with various testing hooks
* @param dummycontainer A dummy container that will be returned as "active" for all queries
*/
public void setupTestHarness(ModContainer dummycontainer)
{
modController = new LoadController(this);
mods = Lists.newArrayList(dummycontainer);
modController.transition(LoaderState.LOADING, false);
modController.transition(LoaderState.CONSTRUCTING, false);
ObjectHolderRegistry.INSTANCE.findObjectHolders(new ASMDataTable());
modController.forceActiveContainer(dummycontainer);
}
/**
* Called from the hook to start mod loading. We trigger the
* {@link #identifyMods()} and Constructing, Preinitalization, and Initalization phases here. Finally,
* the mod list is frozen completely and is consider immutable from then on.
* @param injectedModContainers
* @param injectedModContainers containers to inject
*/
public void loadMods(List<String> injectedModContainers)
{
@@ -65,6 +65,10 @@ public class FMLControlledNamespacedRegistry<I extends IForgeRegistryEntry<I>> e
* Persistent substitutions are the mechanism to allow mods to override specific behaviours with new behaviours.
*/
private final BiMap<ResourceLocation, I> persistentSubstitutions = HashBiMap.create();
/**
* Substitution originals - these are the originals that are being substituted
*/
private final BiMap<ResourceLocation, I> substitutionOriginals = HashBiMap.create();
/**
* This is the current active substitution set for a particular world. It will change as worlds come and go.
*/
@@ -602,6 +606,11 @@ public class FMLControlledNamespacedRegistry<I extends IForgeRegistryEntry<I>> e
I sub = getPersistentSubstitutions().get(nameToReplace);
getExistingDelegate(original).changeReference(sub);
activeSubstitutions.put(nameToReplace, sub);
int id = getIDForObjectBypass(original);
// force the new object into the existing map
addObjectRaw(id, nameToReplace, sub);
// Track the original in the substitution originals collection
substitutionOriginals.put(nameToReplace, original);
return original;
}
return null;
@@ -747,7 +756,11 @@ public class FMLControlledNamespacedRegistry<I extends IForgeRegistryEntry<I>> e
remappedIds.put(itemName, new Integer[] {currId, newId});
}
I obj = currentRegistry.getRaw(itemName);
// If we have an object in the originals set, we use that for initial adding - substitute activation will readd the substitute if neceessary later
if (currentRegistry.substitutionOriginals.containsKey(itemName))
{
obj = currentRegistry.substitutionOriginals.get(itemName);
}
add(newId, itemName, obj);
}
}