当前位置: 首页>>代码示例>>Java>>正文


Java ModContainer.getModId方法代码示例

本文整理汇总了Java中cpw.mods.fml.common.ModContainer.getModId方法的典型用法代码示例。如果您正苦于以下问题:Java ModContainer.getModId方法的具体用法?Java ModContainer.getModId怎么用?Java ModContainer.getModId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cpw.mods.fml.common.ModContainer的用法示例。


在下文中一共展示了ModContainer.getModId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: channelName

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
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);
}
 
开发者ID:4Space,项目名称:4Space-5,代码行数:17,代码来源:PacketCustom.java

示例2: addPrefix

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
/**
 * Prefix the supplied name with the current mod id.
 *
 * If no mod id can be determined, minecraft will be assumed.
 * The prefix is separated with a colon.
 *
 * 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 String addPrefix(String name)
{
    int index = name.lastIndexOf(':');
    String oldPrefix = index == -1 ? "" : name.substring(0, index);
    String prefix;
    ModContainer mc = Loader.instance().activeModContainer();

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

    if (!oldPrefix.equals(prefix))
    {
        name = prefix + ":" + name;
    }

    return name;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:36,代码来源:GameData.java

示例3: registerGlobalEntityID

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id)
{
    if (EntityList.field_75626_c.containsKey(entityClass))
    {
        ModContainer activeModContainer = Loader.instance().activeModContainer();
        String modId = "unknown";
        if (activeModContainer != null)
        {
            modId = activeModContainer.getModId();
        }
        else
        {
            FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped.");
        }
        FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass);
        return;
    }
    id = instance().validateAndClaimId(id);
    EntityList.func_75618_a(entityClass, entityName, id);
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:21,代码来源:EntityRegistry.java

示例4: requestPlayerTicket

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
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;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:19,代码来源:ForgeChunkManager.java

示例5: registerGlobalEntityID

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
public static void registerGlobalEntityID(Class <? extends Entity > entityClass, String entityName, int id)
{
    if (EntityList.classToStringMapping.containsKey(entityClass))
    {
        ModContainer activeModContainer = Loader.instance().activeModContainer();
        String modId = "unknown";
        if (activeModContainer != null)
        {
            modId = activeModContainer.getModId();
        }
        else
        {
            FMLLog.severe("There is a rogue mod failing to register entities from outside the context of mod loading. This is incredibly dangerous and should be stopped.");
        }
        FMLLog.warning("The mod %s tried to register the entity class %s which was already registered - if you wish to override default naming for FML mod entities, register it here first", modId, entityClass);
        return;
    }
    id = instance().validateAndClaimId(id);
    EntityList.addMapping(entityClass, entityName, id);
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:21,代码来源:EntityRegistry.java

示例6: getModID

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
public static String getModID(final ItemStack item) {
    final ModContainer ID = getModForItemStack(item);
    if (ID == null || ID.getModId() == null) {
        return "Unknown";
    }
    return ID.getModId();
}
 
开发者ID:sameer,项目名称:ExtraUtilities,代码行数:8,代码来源:InvHelper.java

示例7: applyModContainer

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
@Override
public void applyModContainer(ModContainer activeContainer)
{
    this.modContainer = activeContainer;
    this.modMetadata = activeContainer.getMetadata();
    this.sourceFile = activeContainer.getSource();
    this.suggestedConfigFile = new File(configurationDir, activeContainer.getModId()+".cfg");
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:9,代码来源:FMLPreInitializationEvent.java

示例8: ticketCountAvailableFor

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
/**
 * Discover the available tickets for the mod in the world
 *
 * @param mod The mod that will own the tickets
 * @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
    {
        return 0;
    }
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:22,代码来源:ForgeChunkManager.java

示例9: requestTicket

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
/**
 * Request a chunkloading ticket of the appropriate type for the supplied mod
 *
 * @param mod The mod requesting a ticket
 * @param world The world in which it is requesting the ticket
 * @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");
    }

    int allowedCount = getMaxTicketLengthFor(modId);

    if (tickets.get(world).get(modId).size() >= allowedCount)
    {
        if (!warnedMods.contains(modId))
        {
            FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount);
            warnedMods.add(modId);
        }
        return null;
    }
    Ticket ticket = new Ticket(modId, type, world);
    tickets.get(world).put(modId, ticket);

    return ticket;
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:40,代码来源:ForgeChunkManager.java

示例10: doLoadOrderHaxing

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
/**
 * We must force the following load order, otherwise many things break:
 *  - TFC
 *  - This mod
 *  - Anything else
 */
public static void doLoadOrderHaxing()
{
    File injectedDepFile = new File(Loader.instance().getConfigDir(), "injectedDependencies.json");

    JsonArray deps = new JsonArray();
    JsonObject dep = new JsonObject();
    dep.addProperty("type", "after");
    dep.addProperty("target", TFC);
    deps.add(dep);

    for (ModContainer container : Loader.instance().getModList())
    {
        if (container instanceof DummyModContainer || container instanceof InjectedModContainer) continue;
        String modid = container.getModId();
        if (modid.equals(MODID) || modid.equals(TFC)) continue;
        dep = new JsonObject();
        dep.addProperty("type", "before");
        dep.addProperty("target", modid);
        deps.add(dep);
    }

    JsonArray root = new JsonArray();
    JsonObject mod = new JsonObject();
    mod.addProperty("modId", MODID);
    mod.add("deps", deps);
    root.add(mod);

    try
    {
        FileUtils.write(injectedDepFile, GSON.toJson(root));
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:dries007,项目名称:TFC-Tweaks,代码行数:43,代码来源:Helper.java

示例11: requestTicket

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
/**
 * Request a chunkloading ticket of the appropriate type for the supplied mod
 *
 * @param mod The mod requesting a ticket
 * @param world The world in which it is requesting the ticket
 * @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");
    }

    int allowedCount = ticketConstraints.containsKey(modId) ? ticketConstraints.get(modId) : defaultMaxCount;

    if (tickets.get(world).get(modId).size() >= allowedCount)
    {
        if (!warnedMods.contains(modId))
        {
            FMLLog.info("The mod %s has attempted to allocate a chunkloading ticket beyond it's currently allocated maximum : %d", modId, allowedCount);
            warnedMods.add(modId);
        }
        return null;
    }
    Ticket ticket = new Ticket(modId, type, world);
    tickets.get(world).put(modId, ticket);

    return ticket;
}
 
开发者ID:alexandrage,项目名称:CauldronGit,代码行数:40,代码来源:ForgeChunkManager.java

示例12: addToReportList

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
static void addToReportList(MCSimpleAnalytics mcSimpleAnalytics) {
	try (ACLock acl = lock.lockAC()) {
		if (!initialized) {
			initialized = true;
			FMLCommonHandler.instance().bus().register(new ActivityReportTickEventHandler());
		}

		// check if an analytics object with the same keys and client status is already in the list
		for (MCSimpleAnalytics analytics : analyticsList) {
			if (analytics.gameKey().equals(mcSimpleAnalytics.gameKey())
					&& analytics.secretKey().equals(mcSimpleAnalytics.secretKey())
					&& (analytics.isClient == mcSimpleAnalytics.isClient)) {
				String mod;
				try {
					ModContainer activeMod = Loader.instance().activeModContainer();
					StringBuilder sb = new StringBuilder(activeMod.getModId());
					sb.append(" -> ").append(activeMod.getName());
					mod = sb.toString();
				} catch (Exception e) {
					mod = "Some mod";
				}
				System.err.println(mod + " tried to instantiate an MCSimpleAnalytics instance with a key pair that was already registered!"
						+ " If you see this message, please report it to the mod developer!");
				return;
			}
		}

		// otherwise add to the list
		analyticsList.add(mcSimpleAnalytics);
	}
}
 
开发者ID:NPException,项目名称:GameAnalyticsAPI,代码行数:32,代码来源:ActivityReportTickEventHandler.java

示例13: GameConfigProvider

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
public GameConfigProvider(String modPrefix) {
    this.modPrefix = modPrefix;

    ModContainer mod = Loader.instance().activeModContainer();
    Preconditions.checkNotNull(mod, "This class can only be initialized in mod init");
    this.modid = mod.getModId();
}
 
开发者ID:awesommist,项目名称:DynamicLib,代码行数:8,代码来源:GameConfigProvider.java

示例14: EntitySpawnMessage

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
public EntitySpawnMessage(EntityRegistration er, Entity entity, ModContainer modContainer)
{
    super(entity);
    modId = modContainer.getModId();
    modEntityTypeId = er.getModEntityId();
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:7,代码来源:FMLMessage.java

示例15: setSender

import cpw.mods.fml.common.ModContainer; //导入方法依赖的package包/类
void setSender(ModContainer activeModContainer)
{
    this.sender = activeModContainer.getModId();
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:5,代码来源:FMLInterModComms.java


注:本文中的cpw.mods.fml.common.ModContainer.getModId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。