use of net.minecraftforge.fml.common.FMLModContainer in project Railcraft by Railcraft.
the class MappingRegistry method getMissingMappingFromFML.
private Object getMissingMappingFromFML(boolean isBlock, String name, int i) {
ResourceLocation location = new ResourceLocation(name);
String modName = name.split(":")[0];
if (Loader.isModLoaded(modName)) {
try {
FMLMissingMappingsEvent.MissingMapping mapping = new FMLMissingMappingsEvent.MissingMapping(isBlock ? GameRegistry.Type.BLOCK : GameRegistry.Type.ITEM, location, i);
ListMultimap<String, FMLMissingMappingsEvent.MissingMapping> missingMapping = ArrayListMultimap.create();
missingMapping.put(modName, mapping);
FMLMissingMappingsEvent event = new FMLMissingMappingsEvent(missingMapping);
for (ModContainer container : Loader.instance().getModList()) {
if (container instanceof FMLModContainer) {
event.applyModContainer(container);
((FMLModContainer) container).handleModStateEvent(event);
if (mapping.getAction() != FMLMissingMappingsEvent.Action.DEFAULT) {
break;
}
}
}
if (mapping.getAction() == FMLMissingMappingsEvent.Action.REMAP) {
return mapping.getTarget();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return null;
}
Aggregations