DefaultResourcePack .java

net.minecraft.client.resources.DefaultResourcePack (class): members: defaultResourceDomains, getInputStreamAssets, mapAssets, getPackMetadata, getPackName.

net.minecraft.client.resourcesclass98 linesclient3.0 KB

Implements

API Surface (7)

InputStream getInputStream(ResourceLocation location)
InputStream getInputStreamAssets(ResourceLocation location)
boolean resourceExists(ResourceLocation location)
Set<String> getResourceDomains()
<T extends IMetadataSection> T getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName)
BufferedImage getPackImage()
String getPackName()

Fields & Constants (2)

defaultResourceDomains
mapAssets

String literals (6)

"minecraft"
"realms"
"/assets/"
"pack.mcmeta"
"pack.png"
"Default"

Code Graph: Dependencies (6)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

DefaultResourcePack.java98 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.resources;
2
3
import com.google.common.collect.ImmutableSet;
4
import java.awt.image.BufferedImage;
5
import java.io.File;
6
import java.io.FileInputStream;
7
import java.io.FileNotFoundException;
8
import java.io.IOException;
9
import java.io.InputStream;
10
import java.util.Map;
11
import java.util.Set;
12
import net.minecraft.client.renderer.texture.TextureUtil;
13
import net.minecraft.client.resources.data.IMetadataSection;
14
import net.minecraft.client.resources.data.IMetadataSerializer;
15
import net.minecraft.util.ResourceLocation;
16
17
public class DefaultResourcePack implements IResourcePack
18
{
19
    public static final Set<String> defaultResourceDomains = ImmutableSet.<String>of("minecraft", "realms");
20
    private final Map<String, File> mapAssets;
21
22
    public DefaultResourcePack(Map<String, File> mapAssetsIn)
23
    {
24
        this.mapAssets = mapAssetsIn;
25
    }
26
27
    public InputStream getInputStream(ResourceLocation location) throws IOException
28
    {
29
        InputStream inputstream = this.getResourceStream(location);
30
31
        if (inputstream != null)
32
        {
33
            return inputstream;
34
        }
35
        else
36
        {
37
            InputStream inputstream1 = this.getInputStreamAssets(location);
38
39
            if (inputstream1 != null)
40
            {
41
                return inputstream1;
42
            }
43
            else
44
            {
45
                throw new FileNotFoundException(location.getResourcePath());
46
            }
47
        }
48
    }
49
50
    public InputStream getInputStreamAssets(ResourceLocation location) throws IOException, FileNotFoundException
51
    {
52
        File file1 = (File)this.mapAssets.get(location.toString());
53
        return file1 != null && file1.isFile() ? new FileInputStream(file1) : null;
54
    }
55
56
    private InputStream getResourceStream(ResourceLocation location)
57
    {
58
        return DefaultResourcePack.class.getResourceAsStream("/assets/" + location.getResourceDomain() + "/" + location.getResourcePath());
59
    }
60
61
    public boolean resourceExists(ResourceLocation location)
62
    {
63
        return this.getResourceStream(location) != null || this.mapAssets.containsKey(location.toString());
64
    }
65
66
    public Set<String> getResourceDomains()
67
    {
68
        return defaultResourceDomains;
69
    }
70
71
    public <T extends IMetadataSection> T getPackMetadata(IMetadataSerializer metadataSerializer, String metadataSectionName) throws IOException
72
    {
73
        try
74
        {
75
            InputStream inputstream = new FileInputStream((File)this.mapAssets.get("pack.mcmeta"));
76
            return AbstractResourcePack.readMetadata(metadataSerializer, inputstream, metadataSectionName);
77
        }
78
        catch (RuntimeException var4)
79
        {
80
            return (T)null;
81
        }
82
        catch (FileNotFoundException var5)
83
        {
84
            return (T)null;
85
        }
86
    }
87
88
    public BufferedImage getPackImage() throws IOException
89
    {
90
        return TextureUtil.readBufferedImage(DefaultResourcePack.class.getResourceAsStream("/" + (new ResourceLocation("pack.png")).getResourcePath()));
91
    }
92
93
    public String getPackName()
94
    {
95
        return "Default";
96
    }
97
}
98

Deobfuscated MCP 1.8.9 source of DefaultResourcePack from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/resources/DefaultResourcePack.java), stored verbatim.