當前位置: 首頁>>代碼示例>>Java>>正文


Java ModContainer類代碼示例

本文整理匯總了Java中net.minecraftforge.fml.common.ModContainer的典型用法代碼示例。如果您正苦於以下問題:Java ModContainer類的具體用法?Java ModContainer怎麽用?Java ModContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ModContainer類屬於net.minecraftforge.fml.common包,在下文中一共展示了ModContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: checkModList

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:22,代碼來源:FMLNetworkHandler.java

示例2: IGWSupportNotifier

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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();
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:26,代碼來源:IGWSupportNotifier.java

示例3: drawScreen

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:21,代碼來源:GuiDupesFound.java

示例4: drawScreen

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:25,代碼來源:GuiSortingProblem.java

示例5: newChannel

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:NetworkRegistry.java

示例6: discover

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
@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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:14,代碼來源:DirectoryDiscoverer.java

示例7: explore

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:12,代碼來源:ModCandidate.java

示例8: ASMEventHandler

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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];
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:ASMEventHandler.java

示例9: addPrefix

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:38,代碼來源:GameData.java

示例10: doModEntityRegistration

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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);
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:28,代碼來源:EntityRegistry.java

示例11: setRegistryName

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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;
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:IForgeRegistryEntry.java

示例12: initGui

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
/**
 * 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;
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:NotificationModUpdateScreen.java

示例13: requestPlayerTicket

import net.minecraftforge.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:F1r3w477,項目名稱:CustomWorldGen,代碼行數:19,代碼來源:ForgeChunkManager.java

示例14: registerBlock

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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;
}
 
開發者ID:Alec-WAM,項目名稱:CrystalMod,代碼行數:24,代碼來源:ModBlocks.java

示例15: registerRitual

import net.minecraftforge.fml.common.ModContainer; //導入依賴的package包/類
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);
}
 
開發者ID:ExoMagica,項目名稱:ExoMagica,代碼行數:19,代碼來源:RitualHandler.java


注:本文中的net.minecraftforge.fml.common.ModContainer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。