BlockFaceUV .java

net.minecraft.client.renderer.block.model.BlockFaceUV (class): members: func_178345_c, func_178346_b, func_178348_a, setUvs, uvs, rotation, Deserializer.

net.minecraft.client.renderer.block.modelclass120 linesclient3.2 KB

API Surface (6)

float func_178348_a(int p_178348_1_)
float func_178346_b(int p_178346_1_)
int func_178345_c(int p_178345_1_)
void setUvs(float[] uvsIn)
BlockFaceUV deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_)
int parseRotation(JsonObject p_178291_1_)

Fields & Constants (2)

uvs
rotation

String literals (4)

"rotation"
"Invalid rotation "
" found, only 0/90/180/270 allowed"
"Expected 4 uv values, found: "

Code Graph: Dependencies (1)

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

Full Source

BlockFaceUV.java120 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.block.model;
2
3
import com.google.gson.JsonArray;
4
import com.google.gson.JsonDeserializationContext;
5
import com.google.gson.JsonDeserializer;
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 net.minecraft.util.JsonUtils;
11
12
public class BlockFaceUV
13
{
14
    public float[] uvs;
15
    public final int rotation;
16
17
    public BlockFaceUV(float[] uvsIn, int rotationIn)
18
    {
19
        this.uvs = uvsIn;
20
        this.rotation = rotationIn;
21
    }
22
23
    public float func_178348_a(int p_178348_1_)
24
    {
25
        if (this.uvs == null)
26
        {
27
            throw new NullPointerException("uvs");
28
        }
29
        else
30
        {
31
            int i = this.func_178347_d(p_178348_1_);
32
            return i != 0 && i != 1 ? this.uvs[2] : this.uvs[0];
33
        }
34
    }
35
36
    public float func_178346_b(int p_178346_1_)
37
    {
38
        if (this.uvs == null)
39
        {
40
            throw new NullPointerException("uvs");
41
        }
42
        else
43
        {
44
            int i = this.func_178347_d(p_178346_1_);
45
            return i != 0 && i != 3 ? this.uvs[3] : this.uvs[1];
46
        }
47
    }
48
49
    private int func_178347_d(int p_178347_1_)
50
    {
51
        return (p_178347_1_ + this.rotation / 90) % 4;
52
    }
53
54
    public int func_178345_c(int p_178345_1_)
55
    {
56
        return (p_178345_1_ + (4 - this.rotation / 90)) % 4;
57
    }
58
59
    public void setUvs(float[] uvsIn)
60
    {
61
        if (this.uvs == null)
62
        {
63
            this.uvs = uvsIn;
64
        }
65
    }
66
67
    static class Deserializer implements JsonDeserializer<BlockFaceUV>
68
    {
69
        public BlockFaceUV deserialize(JsonElement p_deserialize_1_, Type p_deserialize_2_, JsonDeserializationContext p_deserialize_3_) throws JsonParseException
70
        {
71
            JsonObject jsonobject = p_deserialize_1_.getAsJsonObject();
72
            float[] afloat = this.parseUV(jsonobject);
73
            int i = this.parseRotation(jsonobject);
74
            return new BlockFaceUV(afloat, i);
75
        }
76
77
        protected int parseRotation(JsonObject p_178291_1_)
78
        {
79
            int i = JsonUtils.getInt(p_178291_1_, "rotation", 0);
80
81
            if (i >= 0 && i % 90 == 0 && i / 90 <= 3)
82
            {
83
                return i;
84
            }
85
            else
86
            {
87
                throw new JsonParseException("Invalid rotation " + i + " found, only 0/90/180/270 allowed");
88
            }
89
        }
90
91
        private float[] parseUV(JsonObject p_178292_1_)
92
        {
93
            if (!p_178292_1_.has("uv"))
94
            {
95
                return null;
96
            }
97
            else
98
            {
99
                JsonArray jsonarray = JsonUtils.getJsonArray(p_178292_1_, "uv");
100
101
                if (jsonarray.size() != 4)
102
                {
103
                    throw new JsonParseException("Expected 4 uv values, found: " + jsonarray.size());
104
                }
105
                else
106
                {
107
                    float[] afloat = new float[4];
108
109
                    for (int i = 0; i < afloat.length; ++i)
110
                    {
111
                        afloat[i] = JsonUtils.getFloat(jsonarray.get(i), "uv[" + i + "]");
112
                    }
113
114
                    return afloat;
115
                }
116
            }
117
        }
118
    }
119
}
120

Deobfuscated MCP 1.8.9 source of BlockFaceUV from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/renderer/block/model/BlockFaceUV.java), stored verbatim.