Search in sources :

Example 21 with ModContainer

use of net.minecraftforge.fml.common.ModContainer in project MinecraftForge by MinecraftForge.

the class ForgeChunkManager method requestPlayerTicket.

@Nullable
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(ForgeVersion.MOD_ID, ticket);
    return ticket;
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer) Nullable(javax.annotation.Nullable)

Example 22 with ModContainer

use of net.minecraftforge.fml.common.ModContainer in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method finishMinecraftLoading.

/**
     * Called a bit later on during initialization to finish loading mods
     * Also initializes key bindings
     *
     */
public void finishMinecraftLoading() {
    if (modsMissing != null || wrongMC != null || customError != null || dupesFound != null || modSorting != null || j8onlymods != null || multipleModsErrored != null) {
        SplashProgress.finish();
        return;
    }
    try {
        Loader.instance().initializeMods();
    } catch (CustomModLoadingErrorDisplayException custom) {
        FMLLog.log(Level.ERROR, custom, "A custom exception was thrown by a mod, the game will now halt");
        customError = custom;
        SplashProgress.finish();
        return;
    } catch (LoaderException le) {
        haltGame("There was a severe problem during mod loading that has caused the game to fail", le);
        return;
    }
    // Reload resources
    client.refreshResources();
    RenderingRegistry.loadEntityRenderers(Minecraft.getMinecraft().getRenderManager().entityRenderMap);
    guiFactories = HashBiMap.create();
    for (ModContainer mc : Loader.instance().getActiveModList()) {
        String className = mc.getGuiClassName();
        if (Strings.isNullOrEmpty(className)) {
            continue;
        }
        try {
            Class<?> clazz = Class.forName(className, true, Loader.instance().getModClassLoader());
            Class<? extends IModGuiFactory> guiClassFactory = clazz.asSubclass(IModGuiFactory.class);
            IModGuiFactory guiFactory = guiClassFactory.newInstance();
            guiFactory.initialize(client);
            guiFactories.put(mc, guiFactory);
        } catch (Exception e) {
            FMLLog.log(Level.ERROR, e, "A critical error occurred instantiating the gui factory for mod %s", mc.getModId());
        }
    }
    loading = false;
    //Reload options to load any mod added keybindings.
    client.gameSettings.loadOptions();
    Loader.instance().loadingComplete();
    SplashProgress.finish();
}
Also used : LoaderException(net.minecraftforge.fml.common.LoaderException) ForgeModContainer(net.minecraftforge.common.ForgeModContainer) ModContainer(net.minecraftforge.fml.common.ModContainer) DummyModContainer(net.minecraftforge.fml.common.DummyModContainer) WrongMinecraftVersionException(net.minecraftforge.fml.common.WrongMinecraftVersionException) DuplicateModsFoundException(net.minecraftforge.fml.common.DuplicateModsFoundException) LoaderException(net.minecraftforge.fml.common.LoaderException) IOException(java.io.IOException) ModSortingException(net.minecraftforge.fml.common.toposort.ModSortingException) MissingModsException(net.minecraftforge.fml.common.MissingModsException) Java8VersionException(net.minecraftforge.fml.common.Java8VersionException)

Example 23 with ModContainer

use of net.minecraftforge.fml.common.ModContainer in project MinecraftForge by MinecraftForge.

the class GuiModList method reloadMods.

private void reloadMods() {
    ArrayList<ModContainer> mods = modList.getMods();
    mods.clear();
    for (ModContainer m : Loader.instance().getActiveModList()) {
        // If it passes the filter, and is not a child mod
        if (m.getName().toLowerCase().contains(search.getText().toLowerCase()) && m.getMetadata().parentMod == null) {
            mods.add(m);
        }
    }
    this.mods = mods;
    lastFilterText = search.getText();
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer)

Example 24 with ModContainer

use of net.minecraftforge.fml.common.ModContainer in project MinecraftForge by MinecraftForge.

the class FluidRegistry method uniqueName.

private static String uniqueName(Fluid fluid) {
    ModContainer activeModContainer = Loader.instance().activeModContainer();
    String activeModContainerName = activeModContainer == null ? "minecraft" : activeModContainer.getModId();
    return activeModContainerName + ":" + fluid.getName();
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer) NBTTagString(net.minecraft.nbt.NBTTagString)

Example 25 with ModContainer

use of net.minecraftforge.fml.common.ModContainer in project MinecraftForge by MinecraftForge.

the class GuiSlotModList method drawSlot.

@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();
        }
    }
}
Also used : ModContainer(net.minecraftforge.fml.common.ModContainer) CheckResult(net.minecraftforge.common.ForgeVersion.CheckResult) FontRenderer(net.minecraft.client.gui.FontRenderer)

Aggregations

ModContainer (net.minecraftforge.fml.common.ModContainer)36 File (java.io.File)4 ResourceLocation (net.minecraft.util.ResourceLocation)4 DummyModContainer (net.minecraftforge.fml.common.DummyModContainer)4 LoaderException (net.minecraftforge.fml.common.LoaderException)4 IOException (java.io.IOException)3 Nullable (javax.annotation.Nullable)3 ForgeModContainer (net.minecraftforge.common.ForgeModContainer)3 ImmutableMap (com.google.common.collect.ImmutableMap)2 JsonObject (com.google.gson.JsonObject)2 InputStream (java.io.InputStream)2 List (java.util.List)2 Map (java.util.Map)2 BiMap (com.google.common.collect.BiMap)1 HashBiMap (com.google.common.collect.HashBiMap)1 ImmutableSetMultimap (com.google.common.collect.ImmutableSetMultimap)1 SetMultimap (com.google.common.collect.SetMultimap)1 Gson (com.google.gson.Gson)1 JsonArray (com.google.gson.JsonArray)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1