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);
}
use of net.minecraft.client.resources.IResourcePack in project ct.js by ChatTriggers.
the class CTJS method injectResourcePack.
private void injectResourcePack(String path) {
try {
File pictures = new File(path, "ChatTriggers/images/");
Field field = FMLClientHandler.class.getDeclaredField("resourcePackList");
field.setAccessible(true);
List<IResourcePack> packs = (List<IResourcePack>) field.get(FMLClientHandler.instance());
imagesPack = new ImagesPack(pictures);
packs.add(imagesPack);
pictures.mkdirs();
assetsDir = pictures;
} catch (Exception exception) {
exception.printStackTrace();
}
}
use of net.minecraft.client.resources.IResourcePack in project BiomesOPlenty by Glitchfiend.
the class ClientProxy method replaceForgeResources.
private static void replaceForgeResources() {
if (MiscConfigurationHandler.overrideForgeBuckets) {
FMLClientHandler clientHandler = FMLClientHandler.instance();
List<IResourcePack> resourcePackList = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackList");
Map<String, IResourcePack> resourcePackMap = ReflectionHelper.getPrivateValue(FMLClientHandler.class, clientHandler, "resourcePackMap");
LegacyV2Adapter resourcePack = (LegacyV2Adapter) clientHandler.getResourcePackFor("forge");
// Remove the old resource pack from the registry
resourcePackList.remove(resourcePack);
resourcePackMap.remove("forge");
// Replace Forge's resource pack with our modified version
ForgeRedirectedResourcePack redirectedResourcePack = new ForgeRedirectedResourcePack(FMLCommonHandler.instance().findContainerFor("forge"));
// Add our new resource pack in its place
resourcePackList.add(redirectedResourcePack);
resourcePackMap.put("forge", redirectedResourcePack);
}
}
use of net.minecraft.client.resources.IResourcePack in project BetterRain by OreCruncher.
the class PFResourcePackDealer method findResourcePacks.
public List<IResourcePack> findResourcePacks() {
final List<ResourcePackRepository.Entry> repo = Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries();
final List<IResourcePack> foundEntries = new ArrayList<IResourcePack>();
foundEntries.add(new DefaultPack());
// a config file embedded.
for (final ModContainer mod : Loader.instance().getActiveModList()) foundEntries.add(new DefaultPack(mod.getModId()));
for (final ResourcePackRepository.Entry pack : repo) {
ModLog.debug("Resource Pack: %s", pack.getResourcePackName());
if (checkCompatible(pack)) {
ModLog.debug("Found Footsteps resource pack: %s", pack.getResourcePackName());
foundEntries.add(pack.getResourcePack());
}
}
return foundEntries;
}
use of net.minecraft.client.resources.IResourcePack in project BetterRain by OreCruncher.
the class Footsteps method reloadBlockMap.
private void reloadBlockMap(final List<IResourcePack> repo) {
final IBlockMap blockMap = new LegacyCapableBlockMap();
ForgeDictionary.initialize(blockMap);
for (final IResourcePack pack : repo) {
InputStream stream = null;
try {
stream = this.dealer.openBlockMap(pack);
if (stream != null)
Register.setup(ConfigProperty.fromStream(stream), blockMap);
} catch (final IOException e) {
ModLog.debug("Unable to load block map data from pack %s", pack.getPackName());
} finally {
if (stream != null)
try {
stream.close();
} catch (final IOException e) {
;
}
}
}
this.isolator.setBlockMap(blockMap);
}
Aggregations