Search in sources :

Example 1 with FMLModContainer

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;
}
Also used : FMLModContainer(net.minecraftforge.fml.common.FMLModContainer) FMLModContainer(net.minecraftforge.fml.common.FMLModContainer) ModContainer(net.minecraftforge.fml.common.ModContainer) ResourceLocation(net.minecraft.util.ResourceLocation) FMLMissingMappingsEvent(net.minecraftforge.fml.common.event.FMLMissingMappingsEvent)

Aggregations

ResourceLocation (net.minecraft.util.ResourceLocation)1 FMLModContainer (net.minecraftforge.fml.common.FMLModContainer)1 ModContainer (net.minecraftforge.fml.common.ModContainer)1 FMLMissingMappingsEvent (net.minecraftforge.fml.common.event.FMLMissingMappingsEvent)1