Package cpw.mods.fml.common

Examples of cpw.mods.fml.common.ModContainer


        {
            if (i >= size)
            {
                break;
            }
            ModContainer mod = Loader.instance().getModList().get(i);
            OutputHandler.chatNotification(sender, mod.getName() + " - " + mod.getVersion());
        }
    }
View Full Code Here


     * @param mod  The mod instance registering the callback
     * @param callback The code to call back when forced chunks are loaded
     */
    public static void setForcedChunkLoadingCallback(Object mod, LoadingCallback callback)
    {
        ModContainer container = getContainer(mod);
        if (container == null)
        {
            FMLLog.warning("Unable to register a callback for an unknown mod %s (%s : %x)", mod, mod.getClass().getName(), System.identityHashCode(mod));
            return;
        }

        callbacks.put(container.getModId(), callback);
    }
View Full Code Here

     * @param world The world
     * @return The count of tickets left for the mod in the supplied world
     */
    public static int ticketCountAvailableFor(Object mod, World world)
    {
        ModContainer container = getContainer(mod);
        if (container!=null)
        {
            String modId = container.getModId();
            int allowedCount = getMaxTicketLengthFor(modId);
            return allowedCount - tickets.get(world).get(modId).size();
        }
        else
        {
View Full Code Here

        }
    }

    private static ModContainer getContainer(Object mod)
    {
        ModContainer container = Loader.instance().getModObjectList().inverse().get(mod);
        return container;
    }
View Full Code Here

        return playerTicketLength - playerTickets.get(username).size();
    }

    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;
    }
View Full Code Here

     * @param type The type of ticket
     * @return A ticket with which to register chunks for loading, or null if no further tickets are available
     */
    public static Ticket requestTicket(Object mod, World world, Type type)
    {
        ModContainer container = getContainer(mod);
        if (container == 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;
        }
        String modId = container.getModId();
        if (!callbacks.containsKey(modId))
        {
            FMLLog.severe("The mod %s has attempted to request a ticket without a listener in place", modId);
            throw new RuntimeException("Invalid ticket request");
        }
View Full Code Here

        return list;
    }

    public static ConfigCategory getConfigFor(Object mod)
    {
        ModContainer container = getContainer(mod);
        if (container != null)
        {
            return config.getCategory(container.getModId());
        }

        return null;
    }
View Full Code Here

        return null;
    }

    public static void addConfigProperty(Object mod, String propertyName, String value, Property.Type type)
    {
        ModContainer container = getContainer(mod);
        if (container != null)
        {
            ConfigCategory cat = config.getCategory(container.getModId());
            Property prop = new Property(propertyName, value, type).setLanguageKey("forge.configgui." + propertyName);
            if (type == Property.Type.INTEGER)
            {
                prop.setMinValue(0);
            }
View Full Code Here

  public boolean isModLoaded(String modname, String versionRangeString) {
    if (!isModLoaded(modname))
      return false;

    if (versionRangeString != null) {
      ModContainer mod = Loader.instance().getIndexedModList().get(modname);
      ArtifactVersion modVersion = mod.getProcessedVersion();

      VersionRange versionRange = VersionParser.parseRange(versionRangeString);
      DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion(modname, versionRange);

      if (!requiredVersion.containsVersion(modVersion))
View Full Code Here

              String modId = a.values.get(1).toString();
              final String newName = a.values.get(3).toString();
              final String version = a.values.get(5).toString();
              boolean loaded = ModStatusHelper.isModLoaded(modId);
              if(loaded && !version.equals("")) {
                ModContainer mod = Loader.instance().getIndexedModList().get(modId);
                if(mod != null) {
                  VersionRange range = VersionParser.parseRange(version);
                  ArtifactVersion artifactVersion = new DefaultArtifactVersion("Version", mod.getVersion());
                  loaded = range.containsVersion(artifactVersion);
                } else {
                  loaded = false;
                }
              }
View Full Code Here

TOP

Related Classes of cpw.mods.fml.common.ModContainer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.