Search in sources :

Example 6 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project GregTech by GregTechCE.

the class ResourcePackFix method setModResourcePack.

private static void setModResourcePack(String modid, AbstractResourcePack newPack) {
    FMLClientHandler clientHandler = FMLClientHandler.instance();
    IResourcePack oldPack = clientHandler.getResourcePackFor(modid);
    Map<String, IResourcePack> resourcePackMap = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
    resourcePackMap.put(modid, newPack);
    List<IResourcePack> resourcePackList = ObfuscationReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
    resourcePackList.remove(oldPack);
    resourcePackList.add(newPack);
}
Also used : FMLClientHandler(net.minecraftforge.fml.client.FMLClientHandler) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 7 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project GregTech by GregTechCE.

the class ResourcePackFix method getModResourcePack.

private static AbstractResourcePack getModResourcePack(String modid) {
    IResourcePack rawPack = FMLClientHandler.instance().getResourcePackFor(modid);
    AbstractResourcePack resourcePack;
    if (rawPack instanceof LegacyV2Adapter) {
        resourcePack = ObfuscationReflectionHelper.getPrivateValue(LegacyV2Adapter.class, (LegacyV2Adapter) rawPack, 0);
    } else if (rawPack instanceof AbstractResourcePack) {
        resourcePack = (AbstractResourcePack) rawPack;
    } else {
        throw new UnsupportedOperationException("Unknown resource pack class " + rawPack.getClass());
    }
    return resourcePack;
}
Also used : AbstractResourcePack(net.minecraft.client.resources.AbstractResourcePack) LegacyV2Adapter(net.minecraft.client.resources.LegacyV2Adapter) IResourcePack(net.minecraft.client.resources.IResourcePack)

Example 8 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project Hyperium by HyperiumClient.

the class HyperiumMinecraft method preinit.

public void preinit(List<IResourcePack> defaultResourcePacks, DefaultResourcePack mcDefaultResourcePack) {
    Hyperium.INSTANCE.setLaunchTime(System.currentTimeMillis());
    EventBus.INSTANCE.register(Hyperium.INSTANCE);
    defaultResourcePacks.add(mcDefaultResourcePack);
    AddonBootstrap.getAddonResourcePacks().stream().map(file -> file == null ? new AddonWorkspaceResourcePack() : new FileResourcePack(file)).forEach(defaultResourcePacks::add);
    AddonMinecraftBootstrap.init();
    CTJS.loadIntoJVM();
    EventBus.INSTANCE.post(new PreInitializationEvent());
}
Also used : GuiOpenEvent(cc.hyperium.event.gui.GuiOpenEvent) PreInitializationEvent(cc.hyperium.event.client.PreInitializationEvent) Date(java.util.Date) FPSLimiter(cc.hyperium.utils.mods.FPSLimiter) Keyboard(org.lwjgl.input.Keyboard) LWJGLException(org.lwjgl.LWJGLException) ByteBuffer(java.nio.ByteBuffer) CallbackInfoReturnable(org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable) CallbackInfo(org.spongepowered.asm.mixin.injection.callback.CallbackInfo) GuiIngame(net.minecraft.client.gui.GuiIngame) Hyperium(cc.hyperium.Hyperium) EntityPlayerSP(net.minecraft.client.entity.EntityPlayerSP) AddonMinecraftBootstrap(cc.hyperium.internal.addons.AddonMinecraftBootstrap) CTJS(com.chattriggers.ctjs.CTJS) Display(org.lwjgl.opengl.Display) FileResourcePack(net.minecraft.client.resources.FileResourcePack) DefaultResourcePack(net.minecraft.client.resources.DefaultResourcePack) ScaledResolution(net.minecraft.client.gui.ScaledResolution) HyperiumHandlers(cc.hyperium.handlers.HyperiumHandlers) Mouse(org.lwjgl.input.Mouse) WorldChangeEvent(cc.hyperium.event.world.WorldChangeEvent) SplashProgress(cc.hyperium.SplashProgress) List(java.util.List) GuiHyperiumScreenMainMenu(cc.hyperium.gui.GuiHyperiumScreenMainMenu) RenderPlayerEvent(cc.hyperium.event.render.RenderPlayerEvent) Bootstrap(net.minecraft.init.Bootstrap) SingleplayerJoinEvent(cc.hyperium.event.network.server.SingleplayerJoinEvent) Util(net.minecraft.util.Util) SimpleDateFormat(java.text.SimpleDateFormat) WorldClient(net.minecraft.client.multiplayer.WorldClient) Metadata(cc.hyperium.Metadata) Profiler(net.minecraft.profiler.Profiler) IAddon(cc.hyperium.internal.addons.IAddon) AddonBootstrap(cc.hyperium.internal.addons.AddonBootstrap) Minecraft(net.minecraft.client.Minecraft) IResourcePack(net.minecraft.client.resources.IResourcePack) GameSettings(net.minecraft.client.settings.GameSettings) Settings(cc.hyperium.config.Settings) cc.hyperium.event.interact(cc.hyperium.event.interact) RenderManager(net.minecraft.client.renderer.entity.RenderManager) WorldUnloadEvent(cc.hyperium.event.world.WorldUnloadEvent) TickEvent(cc.hyperium.event.client.TickEvent) Timer(net.minecraft.util.Timer) GuiGameOver(net.minecraft.client.gui.GuiGameOver) AddonWorkspaceResourcePack(cc.hyperium.utils.AddonWorkspaceResourcePack) File(java.io.File) InitializationEvent(cc.hyperium.event.client.InitializationEvent) CrashReport(net.minecraft.crash.CrashReport) cc.hyperium.event(cc.hyperium.event) GuiScreen(net.minecraft.client.gui.GuiScreen) DisplayMode(org.lwjgl.opengl.DisplayMode) Utils(cc.hyperium.utils.Utils) InputStream(java.io.InputStream) AddonWorkspaceResourcePack(cc.hyperium.utils.AddonWorkspaceResourcePack) PreInitializationEvent(cc.hyperium.event.client.PreInitializationEvent) FileResourcePack(net.minecraft.client.resources.FileResourcePack)

Example 9 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project MinecraftForge by MinecraftForge.

the class FMLClientHandler method addModAsResource.

@Override
public void addModAsResource(ModContainer container) {
    Class<?> resourcePackType = container.getCustomResourcePackClass();
    if (resourcePackType != null) {
        try {
            IResourcePack pack = (IResourcePack) resourcePackType.getConstructor(ModContainer.class).newInstance(container);
            PackMetadataSection meta = (PackMetadataSection) pack.getPackMetadata(this.metaSerializer, "pack");
            if (meta != null && meta.getPackFormat() == 2) {
                pack = new LegacyV2Adapter(pack);
            }
            resourcePackList.add(pack);
            resourcePackMap.put(container.getModId(), pack);
        } catch (NoSuchMethodException e) {
            FMLLog.log(Level.ERROR, "The container %s (type %s) returned an invalid class for it's resource pack.", container.getName(), container.getClass().getName());
            return;
        } catch (Exception e) {
            FMLLog.log(Level.ERROR, e, "An unexpected exception occurred constructing the custom resource pack for %s", container.getName());
            throw Throwables.propagate(e);
        }
    }
}
Also used : LegacyV2Adapter(net.minecraft.client.resources.LegacyV2Adapter) IResourcePack(net.minecraft.client.resources.IResourcePack) 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) PackMetadataSection(net.minecraft.client.resources.data.PackMetadataSection)

Example 10 with IResourcePack

use of net.minecraft.client.resources.IResourcePack in project MinecraftForge by MinecraftForge.

the class GuiModList method updateCache.

private void updateCache() {
    configModButton.visible = false;
    disableModButton.visible = false;
    modInfo = null;
    if (selectedMod == null)
        return;
    ResourceLocation logoPath = null;
    Dimension logoDims = new Dimension(0, 0);
    List<String> lines = new ArrayList<String>();
    CheckResult vercheck = ForgeVersion.getResult(selectedMod);
    String logoFile = selectedMod.getMetadata().logoFile;
    if (!logoFile.isEmpty()) {
        TextureManager tm = mc.getTextureManager();
        IResourcePack pack = FMLClientHandler.instance().getResourcePackFor(selectedMod.getModId());
        try {
            BufferedImage logo = null;
            if (pack != null) {
                logo = pack.getPackImage();
            } else {
                InputStream logoResource = getClass().getResourceAsStream(logoFile);
                if (logoResource != null)
                    logo = ImageIO.read(logoResource);
            }
            if (logo != null) {
                logoPath = tm.getDynamicTextureLocation("modlogo", new DynamicTexture(logo));
                logoDims = new Dimension(logo.getWidth(), logo.getHeight());
            }
        } catch (IOException e) {
        }
    }
    if (!selectedMod.getMetadata().autogenerated) {
        disableModButton.visible = true;
        disableModButton.enabled = true;
        disableModButton.packedFGColour = 0;
        Disableable disableable = selectedMod.canBeDisabled();
        if (disableable == Disableable.RESTART) {
            disableModButton.packedFGColour = 0xFF3377;
        } else if (disableable != Disableable.YES) {
            disableModButton.enabled = false;
        }
        IModGuiFactory guiFactory = FMLClientHandler.instance().getGuiFactoryFor(selectedMod);
        configModButton.visible = true;
        configModButton.enabled = guiFactory != null && guiFactory.mainConfigGuiClass() != null;
        lines.add(selectedMod.getMetadata().name);
        lines.add(String.format("Version: %s (%s)", selectedMod.getDisplayVersion(), selectedMod.getVersion()));
        lines.add(String.format("Mod ID: '%s' Mod State: %s", selectedMod.getModId(), Loader.instance().getModState(selectedMod)));
        if (!selectedMod.getMetadata().credits.isEmpty()) {
            lines.add("Credits: " + selectedMod.getMetadata().credits);
        }
        lines.add("Authors: " + selectedMod.getMetadata().getAuthorList());
        lines.add("URL: " + selectedMod.getMetadata().url);
        if (selectedMod.getMetadata().childMods.isEmpty())
            lines.add("No child mods for this mod");
        else
            lines.add("Child mods: " + selectedMod.getMetadata().getChildModList());
        if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
            lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
        lines.add(null);
        lines.add(selectedMod.getMetadata().description);
    } else {
        lines.add(WHITE + selectedMod.getName());
        lines.add(WHITE + "Version: " + selectedMod.getVersion());
        lines.add(WHITE + "Mod State: " + Loader.instance().getModState(selectedMod));
        if (vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED)
            lines.add("Update Available: " + (vercheck.url == null ? "" : vercheck.url));
        lines.add(null);
        lines.add(RED + "No mod information found");
        lines.add(RED + "Ask your mod author to provide a mod mcmod.info file");
    }
    if ((vercheck.status == Status.OUTDATED || vercheck.status == Status.BETA_OUTDATED) && vercheck.changes.size() > 0) {
        lines.add(null);
        lines.add("Changes:");
        for (Entry<ComparableVersion, String> entry : vercheck.changes.entrySet()) {
            lines.add("  " + entry.getKey() + ":");
            lines.add(entry.getValue());
            lines.add(null);
        }
    }
    modInfo = new Info(this.width - this.listWidth - 30, lines, logoPath, logoDims);
}
Also used : InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) DynamicTexture(net.minecraft.client.renderer.texture.DynamicTexture) Dimension(java.awt.Dimension) TextComponentString(net.minecraft.util.text.TextComponentString) IOException(java.io.IOException) ComparableVersion(net.minecraftforge.fml.common.versioning.ComparableVersion) IResourcePack(net.minecraft.client.resources.IResourcePack) BufferedImage(java.awt.image.BufferedImage) TextureManager(net.minecraft.client.renderer.texture.TextureManager) ResourceLocation(net.minecraft.util.ResourceLocation) CheckResult(net.minecraftforge.common.ForgeVersion.CheckResult) Disableable(net.minecraftforge.fml.common.ModContainer.Disableable)

Aggregations

IResourcePack (net.minecraft.client.resources.IResourcePack)18 IOException (java.io.IOException)7 InputStream (java.io.InputStream)6 File (java.io.File)5 List (java.util.List)4 LegacyV2Adapter (net.minecraft.client.resources.LegacyV2Adapter)4 FMLClientHandler (net.minecraftforge.fml.client.FMLClientHandler)4 Field (java.lang.reflect.Field)3 ArrayList (java.util.ArrayList)3 FileNotFoundException (java.io.FileNotFoundException)2 Set (java.util.Set)2 AbstractResourcePack (net.minecraft.client.resources.AbstractResourcePack)2 ResourcePackRepository (net.minecraft.client.resources.ResourcePackRepository)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ForgeRedirectedResourcePack (biomesoplenty.client.texture.ForgeRedirectedResourcePack)1 Hyperium (cc.hyperium.Hyperium)1 Metadata (cc.hyperium.Metadata)1 SplashProgress (cc.hyperium.SplashProgress)1 Settings (cc.hyperium.config.Settings)1 cc.hyperium.event (cc.hyperium.event)1