TextureMetadataSectionSerializer .java

net.minecraft.client.resources.data.TextureMetadataSectionSerializer (class, 66 lines): members: getSectionName, deserialize. strings: "mipmaps", "clamp".

net.minecraft.client.resources.dataclass66 linesclientextends BaseMetadataSectionSerializer<TextureMetadataSection>2.4 KB

API Surface (2)

TextureMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_)
String getSectionName()

String literals (7)

"blur"
"clamp"
"mipmaps"
"Invalid texture->mipmap->"
": expected number, was "
"Invalid texture->mipmaps: expected array, was "
"texture"

Code Graph: Dependencies (3)

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

Full Source

TextureMetadataSectionSerializer.java66 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.resources.data;
2
3
import com.google.common.collect.Lists;
4
import com.google.gson.JsonArray;
5
import com.google.gson.JsonDeserializationContext;
6
import com.google.gson.JsonElement;
7
import com.google.gson.JsonObject;
8
import com.google.gson.JsonParseException;
9
import java.lang.reflect.Type;
10
import java.util.List;
11
import net.minecraft.util.JsonUtils;
12
13
public class TextureMetadataSectionSerializer extends BaseMetadataSectionSerializer<TextureMetadataSection>
14
{
15
    public TextureMetadataSection deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
16
    {
17
        JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
18
        boolean flag = JsonUtils.getBoolean(jsonobject, "blur", false);
19
        boolean flag1 = JsonUtils.getBoolean(jsonobject, "clamp", false);
20
        List<Integer> list = Lists.<Integer>newArrayList();
21
22
        if (jsonobject.has("mipmaps"))
23
        {
24
            try
25
            {
26
                JsonArray jsonarray = jsonobject.getAsJsonArray("mipmaps");
27
28
                for (int i = 0; i < jsonarray.size(); ++i)
29
                {
30
                    JsonElement jsonelement = jsonarray.get(i);
31
32
                    if (jsonelement.isJsonPrimitive())
33
                    {
34
                        try
35
                        {
36
                            list.add(Integer.valueOf(jsonelement.getAsInt()));
37
                        }
38
                        catch (NumberFormatException numberformatexception)
39
                        {
40
                            throw new JsonParseException("Invalid texture->mipmap->" + i + ": expected number, was " + jsonelement, numberformatexception);
41
                        }
42
                    }
43
                    else if (jsonelement.isJsonObject())
44
                    {
45
                        throw new JsonParseException("Invalid texture->mipmap->" + i + ": expected number, was " + jsonelement);
46
                    }
47
                }
48
            }
49
            catch (ClassCastException classcastexception)
50
            {
51
                throw new JsonParseException("Invalid texture->mipmaps: expected array, was " + jsonobject.get("mipmaps"), classcastexception);
52
            }
53
        }
54
55
        return new TextureMetadataSection(flag, flag1, list);
56
    }
57
58
    /**
59
     * The name of this section type as it appears in JSON.
60
     */
61
    public String getSectionName()
62
    {
63
        return "texture";
64
    }
65
}
66

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