Java 类net.minecraftforge.fml.common.ModContainer 实例源码

项目:CustomWorldGen    文件:FMLNetworkHandler.java   
public static String checkModList(Map<String,String> listData, Side side)
{
    List<ModContainer> rejects = Lists.newArrayList();
    for (Entry<ModContainer, NetworkModHolder> networkMod : NetworkRegistry.INSTANCE.registry().entrySet())
    {
        boolean result = networkMod.getValue().check(listData, side);
        if (!result)
        {
            rejects.add(networkMod.getKey());
        }
    }
    if (rejects.isEmpty())
    {
        return null;
    }
    else
    {
        FMLLog.info("Rejecting connection %s: %s", side, rejects);
        return String.format("Mod rejections %s",rejects);
    }
}
项目:pnc-repressurized    文件:IGWSupportNotifier.java   
/**
 * Needs to be instantiated somewhere in your mod's loading stage.
 */
public IGWSupportNotifier() {
    if (FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
        File dir = new File(".", "config");
        Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
        config.load();

        if (config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
            ModContainer mc = Loader.instance().activeModContainer();
            String modid = mc.getModId();
            List<ModContainer> loadedMods = Loader.instance().getActiveModList();
            for (ModContainer container : loadedMods) {
                if (container.getModId().equals(modid)) {
                    supportingMod = container.getName();
                    MinecraftForge.EVENT_BUS.register(this);
                    ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
                    break;
                }
            }
        }
        config.save();
    }
}
项目:CustomWorldGen    文件:GuiDupesFound.java   
/**
 * Draws the screen and all the components in it.
 */
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    this.drawDefaultBackground();
    int offset = Math.max(85 - dupes.dupes.size() * 10, 10);
    this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF);
    offset+=10;
    this.drawCenteredString(this.fontRendererObj, "You have mod sources that are duplicate within your system", this.width / 2, offset, 0xFFFFFF);
    offset+=10;
    this.drawCenteredString(this.fontRendererObj, "Mod Id : File name", this.width / 2, offset, 0xFFFFFF);
    offset+=5;
    for (Entry<ModContainer, File> mc : dupes.dupes.entries())
    {
        offset+=10;
        this.drawCenteredString(this.fontRendererObj, String.format("%s : %s", mc.getKey().getModId(), mc.getValue().getName()), this.width / 2, offset, 0xEEEEEE);
    }
}
项目:CustomWorldGen    文件:GuiSortingProblem.java   
/**
 * Draws the screen and all the components in it.
 */
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks)
{
    this.drawDefaultBackground();
    int offset = Math.max(85 - (failedList.getVisitedNodes().size() + 3) * 10, 10);
    this.drawCenteredString(this.fontRendererObj, "Forge Mod Loader has found a problem with your minecraft installation", this.width / 2, offset, 0xFFFFFF);
    offset+=10;
    this.drawCenteredString(this.fontRendererObj, "A mod sorting cycle was detected and loading cannot continue", this.width / 2, offset, 0xFFFFFF);
    offset+=10;
    this.drawCenteredString(this.fontRendererObj, String.format("The first mod in the cycle is %s", failedList.getFirstBadNode()), this.width / 2, offset, 0xFFFFFF);
    offset+=10;
    this.drawCenteredString(this.fontRendererObj, "The remainder of the cycle involves these mods", this.width / 2, offset, 0xFFFFFF);
    offset+=5;
    for (ModContainer mc : failedList.getVisitedNodes())
    {
        offset+=10;
        this.drawCenteredString(this.fontRendererObj, String.format("%s : before: %s, after: %s", mc.toString(), mc.getDependants(), mc.getDependencies()), this.width / 2, offset, 0xEEEEEE);
    }
    offset+=20;
    this.drawCenteredString(this.fontRendererObj, "The file 'ForgeModLoader-client-0.log' contains more information", this.width / 2, offset, 0xFFFFFF);
}
项目:CustomWorldGen    文件:NetworkRegistry.java   
/**
 * INTERNAL Create a new channel pair with the specified name and channel handlers.
 * This is used internally in forge and FML
 *
 * @param container The container to associate the channel with
 * @param name The name for the channel
 * @param handlers Some {@link ChannelHandler} for the channel
 * @return an {@link EnumMap} of the pair of channels. keys are {@link Side}. There will always be two entries.
 */
public EnumMap<Side,FMLEmbeddedChannel> newChannel(ModContainer container, String name, ChannelHandler... handlers)
{
    if (channels.get(Side.CLIENT).containsKey(name) || channels.get(Side.SERVER).containsKey(name) || name.startsWith("MC|") || name.startsWith("\u0001") || (name.startsWith("FML") && !("FML".equals(container.getModId()))))
    {
        throw new RuntimeException("That channel is already registered");
    }
    EnumMap<Side,FMLEmbeddedChannel> result = Maps.newEnumMap(Side.class);

    for (Side side : Side.values())
    {
        FMLEmbeddedChannel channel = new FMLEmbeddedChannel(container, name, side, handlers);
        channels.get(side).put(name,channel);
        result.put(side, channel);
    }
    return result;
}
项目:CustomWorldGen    文件:DirectoryDiscoverer.java   
@Override
public List<ModContainer> discover(ModCandidate candidate, ASMDataTable table)
{
    this.table = table;
    List<ModContainer> found = Lists.newArrayList();
    FMLLog.fine("Examining directory %s for potential mods", candidate.getModContainer().getName());
    exploreFileSystem("", candidate.getModContainer(), found, candidate, null);
    for (ModContainer mc : found)
    {
        table.addContainer(mc);
    }
    return found;
}
项目:CustomWorldGen    文件:ModCandidate.java   
public List<ModContainer> explore(ASMDataTable table)
{
    this.table = table;
    this.mods = sourceType.findMods(this, table);
    if (!baseModCandidateTypes.isEmpty())
    {
        FMLLog.info("Attempting to reparse the mod container %s", getModContainer().getName());
        this.mods = sourceType.findMods(this, table);
    }
    return this.mods;
}
项目:CustomWorldGen    文件:ASMEventHandler.java   
public ASMEventHandler(Object target, Method method, ModContainer owner, boolean isGeneric) throws Exception
{
    this.owner = owner;
    if (Modifier.isStatic(method.getModifiers()))
        handler = (IEventListener)createWrapper(method).newInstance();
    else
        handler = (IEventListener)createWrapper(method).getConstructor(Object.class).newInstance(target);
    subInfo = method.getAnnotation(SubscribeEvent.class);
    readable = "ASM: " + target + " " + method.getName() + Type.getMethodDescriptor(method);
    if (isGeneric)
    {
        java.lang.reflect.Type type = method.getGenericParameterTypes()[0];
        if (type instanceof ParameterizedType)
        {
            filter = ((ParameterizedType)type).getActualTypeArguments()[0];
        }
    }
}
项目:CustomWorldGen    文件:GameData.java   
/**
 * Prefix the supplied name with the current mod id.
 * <p/>
 * If no mod id can be determined, minecraft will be assumed.
 * The prefix is separated with a colon.
 * <p/>
 * If there's already a prefix, it'll be prefixed again if the new prefix
 * doesn't match the old prefix, as used by vanilla calls to addObject.
 *
 * @param name name to prefix.
 * @return prefixed name.
 */
private ResourceLocation addPrefix(String name)
{
    int index = name.lastIndexOf(':');
    String oldPrefix = index == -1 ? "" : name.substring(0, index);
    name = index == -1 ? name : name.substring(index + 1);
    String prefix;
    ModContainer mc = Loader.instance().activeModContainer();

    if (mc != null)
    {
        prefix = mc.getModId().toLowerCase();
    }
    else // no mod container, assume minecraft
    {
        prefix = "minecraft";
    }

    if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
    {
        FMLLog.bigWarning("Dangerous alternative prefix %s for name %s, invalid registry invocation/invalid name?", prefix, name);
        prefix = oldPrefix;
    }

    return new ResourceLocation(prefix, name);
}
项目:CustomWorldGen    文件:EntityRegistry.java   
private void doModEntityRegistration(Class<? extends Entity> entityClass, String entityName, int id, Object mod, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
    ModContainer mc = FMLCommonHandler.instance().findContainerFor(mod);
    EntityRegistration er = new EntityRegistration(mc, entityClass, entityName, id, trackingRange, updateFrequency, sendsVelocityUpdates);
    try
    {
        entityClassRegistrations.put(entityClass, er);
        entityNames.put(entityName, mc);
        if (!EntityList.CLASS_TO_NAME.containsKey(entityClass))
        {
            String entityModName = String.format("%s.%s", mc.getModId(), entityName);
            EntityList.CLASS_TO_NAME.put(entityClass, entityModName);
            EntityList.NAME_TO_CLASS.put(entityModName, entityClass);
            FMLLog.finer("Automatically registered mod %s entity %s as %s", mc.getModId(), entityName, entityModName);
        }
        else
        {
            FMLLog.fine("Skipping automatic mod %s entity registration for already registered class %s", mc.getModId(), entityClass.getName());
        }
    }
    catch (IllegalArgumentException e)
    {
        FMLLog.log(Level.WARN, e, "The mod %s tried to register the entity (name,class) (%s,%s) one or both of which are already registered", mc.getModId(), entityName, entityClass.getName());
        return;
    }
    entityRegistrations.put(mc, er);
}
项目:CustomWorldGen    文件:IForgeRegistryEntry.java   
public final T setRegistryName(String name)
{
    if (getRegistryName() != null)
        throw new IllegalStateException("Attempted to set registry name with existing registry name! New: " + name + " Old: " + getRegistryName());

    int index = name.lastIndexOf(':');
    String oldPrefix = index == -1 ? "" : name.substring(0, index);
    name = index == -1 ? name : name.substring(index + 1);
    ModContainer mc = Loader.instance().activeModContainer();
    String prefix = mc == null || (mc instanceof InjectedModContainer && ((InjectedModContainer)mc).wrappedContainer instanceof FMLContainer) ? "minecraft" : mc.getModId().toLowerCase();
    if (!oldPrefix.equals(prefix) && oldPrefix.length() > 0)
    {
        FMLLog.bigWarning("Dangerous alternative prefix `%s` for name `%s`, expected `%s` invalid registry invocation/invalid name?", oldPrefix, name, prefix);
        prefix = oldPrefix;
    }
    this.registryName = new ResourceLocation(prefix, name);
    return (T)this;
}
项目:CustomWorldGen    文件:NotificationModUpdateScreen.java   
/**
 * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
 * window resizes, the buttonList is cleared beforehand.
 */
@Override
public void initGui()
{
    if (!hasCheckedForUpdates)
    {
        if (modButton != null)
        {
            for (ModContainer mod : Loader.instance().getModList())
            {
                Status status = ForgeVersion.getResult(mod).status;
                if (status == Status.OUTDATED || status == Status.BETA_OUTDATED)
                {
                    // TODO: Needs better visualization, maybe stacked icons
                    // drawn in a terrace-like pattern?
                    showNotification = Status.OUTDATED;
                }
            }
        }
        hasCheckedForUpdates = true;
    }
}
项目:CustomWorldGen    文件:ForgeChunkManager.java   
public static Ticket requestPlayerTicket(Object mod, String player, World world, Type type)
{
    ModContainer mc = getContainer(mod);
    if (mc == null)
    {
        FMLLog.log(Level.ERROR, "Failed to locate the container for mod instance %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
        return null;
    }
    if (playerTickets.get(player).size()>playerTicketLength)
    {
        FMLLog.warning("Unable to assign further chunkloading tickets to player %s (on behalf of mod %s)", player, mc.getModId());
        return null;
    }
    Ticket ticket = new Ticket(mc.getModId(),type,world,player);
    playerTickets.put(player, ticket);
    tickets.get(world).put("Forge", ticket);
    return ticket;
}
项目:CrystalMod    文件:ModBlocks.java   
public static <T extends Block> T registerBlock(T block, ItemBlock itemBlock, String name) {
    String finalName = name;
    String lowerCase = name.toLowerCase();
    if (name != lowerCase) {
        ModLogger.warning("Registering a Block and Item that has a non-lowercase registry name! (" + name + " vs. "
                + lowerCase + ") setting it to " + lowerCase);
        finalName = lowerCase;

        ModContainer mc = Loader.instance().activeModContainer();
        String prefix = mc == null || (mc instanceof InjectedModContainer
                && ((InjectedModContainer) mc).wrappedContainer instanceof FMLContainer) ? "minecraft"
                        : mc.getModId().toLowerCase();
        MissingItemHandler.remapItems.put(new ResourceLocation(prefix, name), itemBlock);
        MissingItemHandler.remapBlocks.put(new ResourceLocation(prefix, name), block);
    }

    block.setUnlocalizedName(CrystalMod.prefix(finalName));
    block.setRegistryName(CrystalMod.resource(finalName));
    GameRegistry.register(block);
    GameRegistry.register(itemBlock.setRegistryName(CrystalMod.resource(finalName)));
    REGISTRY.put(finalName, block);
    return block;
}
项目:ExoMagica    文件:RitualHandler.java   
public static void registerRitual(IRitual ritual, String name) {
    if(Strings.isNullOrEmpty(name)) {
        throw new IllegalArgumentException("Attempted to register a ritual with no name: " + ritual);
    }
    if(ritual == null) {
        throw new NullPointerException("The ritual cannot be null");
    }

    ModContainer mod = Loader.instance().activeModContainer();
    if(mod == null) {
        name = "minecraft:" + name;
    } else {
        name = mod.getModId() + ":" + name;
    }
    HashBiMap<String, IRitualRecipe> recipes = HashBiMap.create();
    NAMED_RITUALS.put(name, ritual);
    RITUALS_RECIPES.put(ritual, recipes);
}
项目:ExoMagica    文件:RitualHandler.java   
public static IRitual getRitual(String ritual) {
    if(Strings.isNullOrEmpty(ritual)) {
        throw new IllegalArgumentException("Attempted to find a ritual with no name: " + ritual);
    }

    if(ritual.indexOf(":") == -1) {
        ModContainer mod = Loader.instance().activeModContainer();
        if(mod == null) {
            ritual = "minecraft:" + ritual;
        } else {
            ritual = mod.getModId() + ":" + ritual;
        }
    }

    return NAMED_RITUALS.get(ritual);
}
项目:DynamicSurroundings    文件:ResourcePacks.java   
@Nonnull
public List<IResourcePack> findResourcePacks() {
    final List<ResourcePackRepository.Entry> repo = Minecraft.getMinecraft().getResourcePackRepository()
            .getRepositoryEntries();

    final List<IResourcePack> foundEntries = new ArrayList<IResourcePack>();
    foundEntries.add(new DefaultPack());

    // Add a default back for mods that are loaded - there may be a default
    // configuration privided in the archive
    for (final ModContainer mod : Loader.instance().getActiveModList())
        foundEntries.add(new DefaultPack(mod.getModId()));

    // Look in other resource packs for more configuration data
    for (final ResourcePackRepository.Entry pack : repo) {
        DSurround.log().debug("Resource Pack: %s", pack.getResourcePackName());
        if (checkCompatible(pack)) {
            DSurround.log().debug("Found FootstepsRegistry resource pack: %s", pack.getResourcePackName());
            foundEntries.add(pack.getResourcePack());
        }
    }
    return foundEntries;
}
项目:DynamicSurroundings    文件:DataScripts.java   
public boolean execute(@Nonnull final List<InputStream> resources) {

        if (!this.init())
            return false;

        for (final ModContainer mod : Loader.instance().getActiveModList()) {
            runFromArchive(mod.getModId());
        }

        for(final InputStream stream: resources) {
            try(final InputStreamReader reader = new InputStreamReader(stream)) {
                runFromStream(reader);
            } catch (final Throwable t) {
                DSurround.log().error("Unable to read script from resource pack!", t);
            }
        }

        // Load scripts specified in the configuration
        final String[] configFiles = ModOptions.externalScriptFiles;
        for (final String file : configFiles) {
            runFromDirectory(file);
        }

        return true;
    }
项目:BIGB    文件:ItemInfo.java   
private static void parseModItems() {
    HashMap<String, ItemStackSet> modSubsets = new HashMap<String, ItemStackSet>();
    for (Item item : (Iterable<Item>) Item.itemRegistry) {
        UniqueIdentifier ident = GameRegistry.findUniqueIdentifierFor(item);
        if(ident == null) {
            NEIClientConfig.logger.error("Failed to find identifier for: "+item);
            continue;
        }
        String modId = GameRegistry.findUniqueIdentifierFor(item).modId;
        itemOwners.put(item, modId);
        ItemStackSet itemset = modSubsets.get(modId);
        if(itemset == null)
            modSubsets.put(modId, itemset = new ItemStackSet());
        itemset.with(item);
    }

    API.addSubset("Mod.Minecraft", modSubsets.remove("minecraft"));
    for(Entry<String, ItemStackSet> entry : modSubsets.entrySet()) {
        ModContainer mc = FMLCommonHandler.instance().findContainerFor(entry.getKey());
        if(mc == null)
            NEIClientConfig.logger.error("Missing container for "+entry.getKey());
        else
            API.addSubset("Mod."+mc.getName(), entry.getValue());
    }
}
项目:CodeChickenLib    文件:PacketCustom.java   
public static String channelName(Object channelKey) {

        if (channelKey instanceof String) {
            return (String) channelKey;
        }
        if (channelKey instanceof ModContainer) {
            String s = ((ModContainer) channelKey).getModId();
            if (s.length() > 20) {
                throw new IllegalArgumentException("Mod ID (" + s + ") too long for use as channel (20 chars). Use a string identifier");
            }
            return s;
        }

        ModContainer mc = FMLCommonHandler.instance().findContainerFor(channelKey);
        if (mc != null) {
            return mc.getModId();
        }

        throw new IllegalArgumentException("Invalid channel: " + channelKey);
    }
项目:Alchemy    文件:AlchemyDLCLoader.java   
@Unsafe(Unsafe.REFLECT_API)
protected void injectLoader() {
    List<ModContainer> mods = $(Loader.instance(), "mods");
    $(Loader.instance(), "mods<", ImmutableList.builder().addAll(mods).add(this).build());
    $(Loader.instance(), "namedMods<", Maps.uniqueIndex(mods, ModContainer::getModId));
    LoadController modController = $(Loader.instance(), "modController");
    Multimap<String, ModState> modStates = $(modController, "modStates");
    modStates.put(getModId(), ModState.AVAILABLE);
    Map<String, String> modNames = $(modController, "modNames");
    modNames.put(getModId(), getName());
    List<ModContainer> activeModList = $(modController, "activeModList");
    activeModList = Lists.newArrayList(activeModList);
    activeModList.add(this);
    $(modController, "activeModList<", activeModList);
    ImmutableMap<String,EventBus> eventChannels = $(modController, "eventChannels");
    $(modController, "eventChannels<", ImmutableMap.builder().putAll(eventChannels).put(getModId(), new EventBus()).build());
}
项目:EverythingBlocks    文件:ForgeUtils.java   
/** Get the name of a mod from its mod ID (non-case sensitive) */
public static String getModNameFromID(String modid) {
    modid = modid.toLowerCase();
    if(modid.equals("minecraft")) return "Minecraft";
    if(nameCache.containsKey(modid)) {
        return nameCache.get(modid);
    } else {
        List<ModContainer> modlist = Loader.instance().getModList();
        for(ModContainer m : modlist) {
            if(m.getModId().toLowerCase().equals(modid)) {
                nameCache.put(modid, m.getName());
                return m.getName();
            }
        }
        return ERROR;
    }
}
项目:Factorization    文件:DocumentationModule.java   
@Mod.EventHandler
public void init(FMLPreInitializationEvent event) {
    FzUtil.setCoreParent(event);
    DocReg.registerGenerator("items", new ItemListViewer());
    DocReg.registerGenerator("recipes", new RecipeViewer());
    DocReg.registerGenerator("enchants", new EnchantViewer());
    DocReg.registerGenerator("treasure", new TreasureViewer());
    DocReg.registerGenerator("biomes", new BiomeViewer());
    DocReg.registerGenerator("fluids", new FluidViewer());
    DocReg.registerGenerator("oredictionary", new OreDictionaryViewer());
    DocReg.registerGenerator("mods", new ModDependViewer());
    DocReg.registerGenerator("worldgen", new WorldgenViewer());
    DocReg.registerGenerator("eventbus", new EventbusViewer());
    DocReg.registerGenerator("tesrs", new TesrViewer());
    DocReg.registerGenerator("registry", new RegistrationViewer());
    if (FMLCommonHandler.instance().getSide() == Side.CLIENT) {
        Core.loadBus(new DocKeyListener());
    }

    for (ModContainer mod : Loader.instance().getActiveModList()) {
        DocReg.setVariable("mod:" + mod.getModId(), mod.getName());
    }

    registerCommands();
}
项目:MoarSigns    文件:Utils.java   
public static String getModName(String modID) {
    Map<String, ModContainer> mods = Loader.instance().getIndexedModList();
    if (mods.containsKey(modID)) {
        return mods.get(modID).getName();
    }

    if (modNames.containsKey(modID))
        return modNames.get(modID);

    ISignRegistration registration = IntegrationRegistry.getWithTag(modID);
    if (registration != null) {
        modNames.put(modID, registration.getModName());
        return registration.getModName();
    }

    return "Minecraft";
}
项目:Pulsar    文件:PulseManager.java   
/**
 * Helper to attach a given object to the mod container event bus.
 *
 * @param obj Object to register.
 */
private void attachToContainerEventBus(Object obj) {
    ModContainer cnt =  Loader.instance().activeModContainer();
    log.debug("Attaching [" + obj + "] to event bus for container [" + cnt + "]");
    try {
        FMLModContainer mc = (FMLModContainer)cnt;
        Field ebf = mc.getClass().getDeclaredField("eventBus");

        boolean access = ebf.isAccessible();
        ebf.setAccessible(true);
        EventBus eb = (EventBus)ebf.get(mc);
        ebf.setAccessible(access);

        eb.register(obj);
    } catch (NoSuchFieldException nsfe) {
        throw new RuntimeException("Pulsar >> Incompatible FML mod container (missing eventBus field) - wrong Forge version?");
    } catch (IllegalAccessException iae) {
        throw new RuntimeException("Pulsar >> Security Manager blocked access to eventBus on mod container. Cannot continue.");
    } catch (ClassCastException cce) {
        throw new RuntimeException("Pulsar >> Something in the mod container had the wrong type? " + cce.getMessage());
    }
}
项目:FloodLights    文件:IGWSupportNotifier.java   
/**
 * Needs to be instantiated somewhere in your mod's loading stage.
 */
public IGWSupportNotifier(){
    if(FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
        File dir = new File(".", "config");
        Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
        config.load();

        if(config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
            ModContainer mc = Loader.instance().activeModContainer();
            String modid = mc.getModId();
            List<ModContainer> loadedMods = Loader.instance().getActiveModList();
            for(ModContainer container : loadedMods) {
                if(container.getModId().equals(modid)) {
                    supportingMod = container.getName();
                    MinecraftForge.EVENT_BUS.register(this);
                    ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
                    break;
                }
            }
        }
        config.save();
    }
}
项目:IGW-mod    文件:IGWSupportNotifier.java   
/**
 * Needs to be instantiated somewhere in your mod's loading stage.
 */
public IGWSupportNotifier(){
    if(FMLCommonHandler.instance().getSide() == Side.CLIENT && !Loader.isModLoaded("IGWMod")) {
        File dir = new File(".", "config");
        Configuration config = new Configuration(new File(dir, "IGWMod.cfg"));
        config.load();

        if(config.get(Configuration.CATEGORY_GENERAL, "enable_missing_notification", true, "When enabled, this will notify players when IGW-Mod is not installed even though mods add support.").getBoolean()) {
            ModContainer mc = Loader.instance().activeModContainer();
            String modid = mc.getModId();
            List<ModContainer> loadedMods = Loader.instance().getActiveModList();
            for(ModContainer container : loadedMods) {
                if(container.getModId().equals(modid)) {
                    supportingMod = container.getName();
                    MinecraftForge.EVENT_BUS.register(this);
                    ClientCommandHandler.instance.registerCommand(new CommandDownloadIGW());
                    break;
                }
            }
        }
        config.save();
    }
}
项目:IGW-mod    文件:Util.java   
public static String getModIdForEntity(Class<? extends Entity> entity){
    if(reflectionFailed) return "minecraft";
    if(entityNames == null) {
        try {
            entityNames = (HashMap<String, ModContainer>)ReflectionHelper.findField(EntityRegistry.class, "entityNames").get(EntityRegistry.instance());
        } catch(Exception e) {
            IGWLog.warning("IGW-Mod failed to perform reflection! A result of this is that wiki pages related to Entities will not be found. Report to MineMaarten please!");
            e.printStackTrace();
            reflectionFailed = true;
            return "minecraft";
        }
    }
    EntityRegistration entityReg = EntityRegistry.instance().lookupModSpawn(entity, true);
    if(entityReg == null) return "minecraft";
    ModContainer mod = entityNames.get(entityReg.getEntityName());
    if(mod == null) {
        IGWLog.info("Couldn't find the owning mod of the entity " + entityReg.getEntityName() + " even though it's registered through the EntityRegistry!");
        return "minecraft";
    } else {
        return mod.getModId().toLowerCase();
    }
}
项目:EnderIO    文件:GuiConfigFactoryEIO.java   
private static List<IConfigElement> getConfigElements(GuiScreen parent) {
  List<IConfigElement> result = new ArrayList<>();
  List<ModContainer> modList = Loader.instance().getModList();
  for (ModContainer modContainer : modList) {
    Object mod = modContainer.getMod();
    if (mod instanceof IEnderIOAddon) {
      Configuration configuration = ((IEnderIOAddon) mod).getConfiguration();
      if (configuration != null) {
        List<IConfigElement> list = new ArrayList<>();
        for (String section : configuration.getCategoryNames()) {
          list.add(new ConfigElement(configuration.getCategory(section).setLanguageKey(EnderIO.lang.addPrefix("config." + section))));
        }
        result.add(new DummyCategoryElement(modContainer.getName(), EnderIO.lang.addPrefix("config.title." + modContainer.getModId()), list));
      }
    }
  }

  return result;
}
项目:HeroUtils    文件:ObjectDefinition.java   
protected static String getCurrentMod() {
    ModContainer container = Loader.instance().activeModContainer();
    if (container == null) {
        throw new IllegalStateException("Objects MUST be created inside a mod");
    }
    return container.getModId();
}
项目:HeroUtils    文件:RotorRegistry.java   
/**
 * Sets the internal Registry instance.
 * ONLY IC2 CAN DO THIS!!!!!!!
 */
public static void setInstance(IRotorRegistry i) {
    ModContainer mc = Loader.instance().activeModContainer();
    if (mc == null || !"IC2".equals(mc.getModId())) {
        throw new IllegalAccessError("Only IC2 can set the instance");
    } else {
        INSTANCE = i;
    }
}
项目:HeroUtils    文件:NetworkHelper.java   
/**
 * Sets the internal INetworkManager instance.
 * ONLY IC2 CAN DO THIS!!!!!!!
 */
public static void setInstance(INetworkManager server, INetworkManager client) {
    ModContainer mc = Loader.instance().activeModContainer();
    if (mc == null || !"IC2".equals(mc.getModId())) {
        throw new IllegalAccessError();
    }
    serverInstance = server;
    clientInstance = client;
}
项目:HeroUtils    文件:IC2Items.java   
/**
 * Sets the internal IItemAPI instance.
 * ONLY IC2 CAN DO THIS!!!!!!!
 */
public static void setInstance(IItemAPI api) {
    ModContainer mc = Loader.instance().activeModContainer();

    if (mc == null || !"IC2".equals(mc.getModId())) {
        throw new IllegalAccessError("invoked from "+mc);
    }

    instance = api;
}
项目:CreeperKiller    文件:CreeperKiller.java   
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent e) {
    LOG = e.getModLog();

    Map<Object, ModContainer> forgeListenerOwners = getForgeListenerOwners();
    // Remove CreeperHost ads.
    forgeListenerOwners.entrySet().stream()
            .filter(objectModContainerEntry -> objectModContainerEntry.getValue().getModId().equals("creeperhost"))
            .forEach(objectModContainerEntry -> {
                        LOG.info("CreeperKiller Removed {} handler from forge, CreeperHost ads will no longer be displayed", objectModContainerEntry.getKey().toString());
                        MinecraftForge.EVENT_BUS.unregister(objectModContainerEntry.getKey());
                    }
            );
}
项目:CreeperKiller    文件:CreeperKiller.java   
@Mod.EventHandler
public void init(FMLInitializationEvent e) {
    Map<Object, ModContainer> forgeListenerOwners = getForgeListenerOwners();

    // Remove HammerCore ads.
    forgeListenerOwners.entrySet().stream()
            .filter(objectModContainerEntry -> objectModContainerEntry.getKey().toString().contains("hammercore.client.RenderGui"))
            .forEach(objectModContainerEntry -> {
                // Remove the normal RenderGUI from the forge event bus, then generate a proxy.
                MinecraftForge.EVENT_BUS.unregister(objectModContainerEntry.getKey());
                MinecraftForge.EVENT_BUS.register(HammerKiller.createProxy(objectModContainerEntry.getKey()));
            });
}
项目:CreeperKiller    文件:CreeperKiller.java   
public static Map<Object, ModContainer> getForgeListenerOwners() {
    try {
        return ((Map<Object, ModContainer>) FieldUtils.readField(MinecraftForge.EVENT_BUS, "listenerOwners", true));
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }
    return null;
}
项目:UniversalRemote    文件:Util.java   
public static String getModNameFromID(String modid)
{
    String result = "Unknown";

    for (ModContainer mod : Loader.instance().getModList())
    {
        if (mod.getModId().equals(modid))
        {
            result = mod.getName();
            break;
        }
    }

    return result;
}
项目:customstuff4    文件:ModLoader.java   
private static ContentHelper createHelper(CS4Mod mod)
{
    ModContainer container = FMLCommonHandler.instance().findContainerFor(mod);
    File modDirectory = container.getSource();

    return new ContentHelperImpl(container.getModId(), modDirectory);
}
项目:CustomWorldGen    文件:FMLClientHandler.java   
/**
 * @param mods
 */
public void addSpecialModEntries(ArrayList<ModContainer> mods)
{
    if (optifineContainer!=null) {
        mods.add(optifineContainer);
    }
}
项目:CustomWorldGen    文件:GuiSlotModList.java   
@Override
protected void drawSlot(int idx, int right, int top, int height, Tessellator tess)
{
    ModContainer mc       = mods.get(idx);
    String       name     = StringUtils.stripControlCodes(mc.getName());
    String       version  = StringUtils.stripControlCodes(mc.getDisplayVersion());
    FontRenderer font     = this.parent.getFontRenderer();
    CheckResult  vercheck = ForgeVersion.getResult(mc);

    if (Loader.instance().getModState(mc) == ModState.DISABLED)
    {
        font.drawString(font.trimStringToWidth(name,       listWidth - 10), this.left + 3 , top +  2, 0xFF2222);
        font.drawString(font.trimStringToWidth(version,    listWidth - (5 + height)), this.left + 3 , top + 12, 0xFF2222);
        font.drawString(font.trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , top + 22, 0xFF2222);
    }
    else
    {
        font.drawString(font.trimStringToWidth(name,    listWidth - 10), this.left + 3 , top +  2, 0xFFFFFF);
        font.drawString(font.trimStringToWidth(version, listWidth - (5 + height)), this.left + 3 , top + 12, 0xCCCCCC);
        font.drawString(font.trimStringToWidth(mc.getMetadata() != null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , top + 22, 0xCCCCCC);

        if (vercheck.status.shouldDraw())
        {
            //TODO: Consider adding more icons for visualization
            Minecraft.getMinecraft().getTextureManager().bindTexture(VERSION_CHECK_ICONS);
            GlStateManager.color(1, 1, 1, 1);
            GlStateManager.pushMatrix();
            Gui.drawModalRectWithCustomSizedTexture(right - (height / 2 + 4), top + (height / 2 - 4), vercheck.status.getSheetOffset() * 8, (vercheck.status.isAnimated() && ((System.currentTimeMillis() / 800 & 1)) == 1) ? 8 : 0, 8, 8, 64, 16);
            GlStateManager.popMatrix();
        }
    }
}