Search in sources :

Example 26 with IResource

use of net.minecraft.client.resources.IResource in project DynamicSurroundings by OreCruncher.

the class SpeechBubbleHandler method loadText.

private void loadText() {
    final String[] langs;
    if (Minecraft.getMinecraft().gameSettings.language.equals(Translations.DEFAULT_LANGUAGE))
        langs = new String[] { Translations.DEFAULT_LANGUAGE };
    else
        langs = new String[] { Translations.DEFAULT_LANGUAGE, Minecraft.getMinecraft().gameSettings.language };
    this.xlate.load("/assets/dsurround/data/chat/", langs);
    this.xlate.transform(new Stripper());
    try (final IResource resource = Minecraft.getMinecraft().getResourceManager().getResource(SPLASH_TEXT)) {
        @SuppressWarnings("deprecation") final BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(resource.getInputStream(), Charsets.UTF_8));
        String s;
        while ((s = bufferedreader.readLine()) != null) {
            s = s.trim();
            if (!s.isEmpty()) {
                this.minecraftSplashText.add(s);
            }
        }
    } catch (final Throwable t) {
        ;
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IResource(net.minecraft.client.resources.IResource)

Example 27 with IResource

use of net.minecraft.client.resources.IResource in project DynamicSurroundings by OreCruncher.

the class ProxyClient method preInit.

@Override
public void preInit(@Nonnull final FMLPreInitializationEvent event) {
    super.preInit(event);
    // Extract the preset config files present in the JAR
    final IResourceManager manager = Minecraft.getMinecraft().getResourceManager();
    for (final String preset : presetFiles) {
        final String name = preset + ".presets";
        try {
            final IResource r = manager.getResource(new ResourceLocation(Presets.MOD_ID, "data/" + name));
            try (final InputStream stream = r.getInputStream()) {
                Streams.copy(stream, new File(Presets.dataDirectory(), name));
            }
        } catch (final Throwable t) {
            Presets.log().error("Unable to extract preset file " + name, t);
        }
    }
}
Also used : InputStream(java.io.InputStream) ResourceLocation(net.minecraft.util.ResourceLocation) IResourceManager(net.minecraft.client.resources.IResourceManager) File(java.io.File) IResource(net.minecraft.client.resources.IResource)

Example 28 with IResource

use of net.minecraft.client.resources.IResource in project EnderIO by SleepyTrousers.

the class DynaTextureProvider method getTexture.

protected BufferedImage getTexture(@Nonnull ResourceLocation blockResource) {
    try {
        IResource iResource = resourceManager.getResource(blockResource);
        BufferedImage image = ImageIO.read(iResource.getInputStream());
        iResource.close();
        return image;
    } catch (IOException e) {
        Log.error("Failed to load " + blockResource + ": " + e);
    }
    return null;
}
Also used : IOException(java.io.IOException) IResource(net.minecraft.client.resources.IResource) BufferedImage(java.awt.image.BufferedImage)

Example 29 with IResource

use of net.minecraft.client.resources.IResource in project EnderIO by SleepyTrousers.

the class DynaTextureProvider method getTexture.

protected BufferedImage getTexture(@Nonnull ResourceLocation blockResource) {
    try {
        IResource iResource = resourceManager.getResource(blockResource);
        BufferedImage image = ImageIO.read(iResource.getInputStream());
        iResource.close();
        return image;
    } catch (IOException e) {
        Log.error("Failed to load " + blockResource + ": " + e);
    }
    return null;
}
Also used : IOException(java.io.IOException) IResource(net.minecraft.client.resources.IResource) BufferedImage(java.awt.image.BufferedImage)

Example 30 with IResource

use of net.minecraft.client.resources.IResource in project ForestryMC by ForestryMC.

the class ModelUtil method getReaderForResource.

private static Reader getReaderForResource(ResourceLocation location) throws IOException {
    ResourceLocation file = new ResourceLocation(location.getResourceDomain(), location.getResourcePath() + ".json");
    IResource iresource = Minecraft.getMinecraft().getResourceManager().getResource(file);
    return new BufferedReader(new InputStreamReader(iresource.getInputStream(), Charsets.UTF_8));
}
Also used : InputStreamReader(java.io.InputStreamReader) ResourceLocation(net.minecraft.util.ResourceLocation) BufferedReader(java.io.BufferedReader) IResource(net.minecraft.client.resources.IResource)

Aggregations

IResource (net.minecraft.client.resources.IResource)38 IOException (java.io.IOException)23 ResourceLocation (net.minecraft.util.ResourceLocation)21 InputStreamReader (java.io.InputStreamReader)12 BufferedImage (java.awt.image.BufferedImage)9 IResourceManager (net.minecraft.client.resources.IResourceManager)8 BufferedReader (java.io.BufferedReader)6 JsonObject (com.google.gson.JsonObject)3 FileNotFoundException (java.io.FileNotFoundException)3 InputStream (java.io.InputStream)3 Nullable (javax.annotation.Nullable)3 PngSizeInfo (net.minecraft.client.renderer.texture.PngSizeInfo)3 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)3 IModel (net.minecraftforge.client.model.IModel)3 JsonElement (com.google.gson.JsonElement)2 RasterFormatException (java.awt.image.RasterFormatException)2 Minecraft (net.minecraft.client.Minecraft)2 CrashReport (net.minecraft.crash.CrashReport)2 CrashReportCategory (net.minecraft.crash.CrashReportCategory)2 ReportedException (net.minecraft.util.ReportedException)2