use of net.minecraftforge.fml.common.event.FMLStateEvent in project MinecraftForge by MinecraftForge.
the class LoadController method sendEventToModContainer.
private void sendEventToModContainer(FMLEvent stateEvent, ModContainer mc) {
String modId = mc.getModId();
Collection<String> requirements = Collections2.transform(mc.getRequirements(), new ArtifactVersionNameFunction());
for (ArtifactVersion av : mc.getDependencies()) {
if (av.getLabel() != null && requirements.contains(av.getLabel()) && modStates.containsEntry(av.getLabel(), ModState.ERRORED)) {
FMLLog.log(modId, Level.ERROR, "Skipping event %s and marking errored mod %s since required dependency %s has errored", stateEvent.getEventType(), modId, av.getLabel());
modStates.put(modId, ModState.ERRORED);
return;
}
}
activeContainer = mc;
stateEvent.applyModContainer(mc);
ThreadContext.put("mod", modId);
FMLLog.log(modId, Level.TRACE, "Sending event %s to mod %s", stateEvent.getEventType(), modId);
eventChannels.get(modId).post(stateEvent);
FMLLog.log(modId, Level.TRACE, "Sent event %s to mod %s", stateEvent.getEventType(), modId);
ThreadContext.remove("mod");
activeContainer = null;
if (stateEvent instanceof FMLStateEvent) {
if (!errors.containsKey(modId)) {
modStates.put(modId, ((FMLStateEvent) stateEvent).getModState());
} else {
modStates.put(modId, ModState.ERRORED);
}
}
}
Aggregations