use of net.minecraft.client.resources.IResourcePack in project CatServer by Luohuayu.
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 = false;
if (guiFactory != null) {
configModButton.enabled = guiFactory.hasConfigGui();
}
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);
}
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);
}
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;
}
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());
}
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);
}
}
}
Aggregations