VertexFormatElement .java

net.minecraft.client.renderer.vertex.VertexFormatElement (class, 157 lines): members: isPositionElement, elementCount, EnumUsage, getUsage, usage, getType.

net.minecraft.client.renderer.vertexclass157 linesclient4.0 KB

API Surface (13)

VertexFormatElement.EnumType getType()
VertexFormatElement.EnumUsage getUsage()
int getElementCount()
int getIndex()
String toString()
int getSize()
boolean isPositionElement()
boolean equals(Object p_equals_1_)
int hashCode()
int getSize()
String getDisplayName()
int getGlConstant()
String getDisplayName()

Fields & Constants (5)

LOGGER
type
usage
index
elementCount

String literals (12)

"Float"
"Unsigned Byte"
"Byte"
"Unsigned Short"
"Short"
"Unsigned Int"
"Position"
"Normal"
"Vertex Color"
"Bone Matrix"
"Blend Weight"
"Padding"

Full Source

VertexFormatElement.java157 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.renderer.vertex;
2
3
import org.apache.logging.log4j.LogManager;
4
import org.apache.logging.log4j.Logger;
5
6
public class VertexFormatElement
7
{
8
    private static final Logger LOGGER = LogManager.getLogger();
9
    private final VertexFormatElement.EnumType type;
10
    private final VertexFormatElement.EnumUsage usage;
11
    private int index;
12
    private int elementCount;
13
14
    public VertexFormatElement(int indexIn, VertexFormatElement.EnumType typeIn, VertexFormatElement.EnumUsage usageIn, int count)
15
    {
16
        if (!this.func_177372_a(indexIn, usageIn))
17
        {
18
            LOGGER.warn("Multiple vertex elements of the same type other than UVs are not supported. Forcing type to UV.");
19
            this.usage = VertexFormatElement.EnumUsage.UV;
20
        }
21
        else
22
        {
23
            this.usage = usageIn;
24
        }
25
26
        this.type = typeIn;
27
        this.index = indexIn;
28
        this.elementCount = count;
29
    }
30
31
    private final boolean func_177372_a(int p_177372_1_, VertexFormatElement.EnumUsage p_177372_2_)
32
    {
33
        return p_177372_1_ == 0 || p_177372_2_ == VertexFormatElement.EnumUsage.UV;
34
    }
35
36
    public final VertexFormatElement.EnumType getType()
37
    {
38
        return this.type;
39
    }
40
41
    public final VertexFormatElement.EnumUsage getUsage()
42
    {
43
        return this.usage;
44
    }
45
46
    public final int getElementCount()
47
    {
48
        return this.elementCount;
49
    }
50
51
    public final int getIndex()
52
    {
53
        return this.index;
54
    }
55
56
    public String toString()
57
    {
58
        return this.elementCount + "," + this.usage.getDisplayName() + "," + this.type.getDisplayName();
59
    }
60
61
    public final int getSize()
62
    {
63
        return this.type.getSize() * this.elementCount;
64
    }
65
66
    public final boolean isPositionElement()
67
    {
68
        return this.usage == VertexFormatElement.EnumUsage.POSITION;
69
    }
70
71
    public boolean equals(Object p_equals_1_)
72
    {
73
        if (this == p_equals_1_)
74
        {
75
            return true;
76
        }
77
        else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass())
78
        {
79
            VertexFormatElement vertexformatelement = (VertexFormatElement)p_equals_1_;
80
            return this.elementCount != vertexformatelement.elementCount ? false : (this.index != vertexformatelement.index ? false : (this.type != vertexformatelement.type ? false : this.usage == vertexformatelement.usage));
81
        }
82
        else
83
        {
84
            return false;
85
        }
86
    }
87
88
    public int hashCode()
89
    {
90
        int i = this.type.hashCode();
91
        i = 31 * i + this.usage.hashCode();
92
        i = 31 * i + this.index;
93
        i = 31 * i + this.elementCount;
94
        return i;
95
    }
96
97
    public static enum EnumType
98
    {
99
        FLOAT(4, "Float", 5126),
100
        UBYTE(1, "Unsigned Byte", 5121),
101
        BYTE(1, "Byte", 5120),
102
        USHORT(2, "Unsigned Short", 5123),
103
        SHORT(2, "Short", 5122),
104
        UINT(4, "Unsigned Int", 5125),
105
        INT(4, "Int", 5124);
106
107
        private final int size;
108
        private final String displayName;
109
        private final int glConstant;
110
111
        private EnumType(int sizeIn, String displayNameIn, int glConstantIn)
112
        {
113
            this.size = sizeIn;
114
            this.displayName = displayNameIn;
115
            this.glConstant = glConstantIn;
116
        }
117
118
        public int getSize()
119
        {
120
            return this.size;
121
        }
122
123
        public String getDisplayName()
124
        {
125
            return this.displayName;
126
        }
127
128
        public int getGlConstant()
129
        {
130
            return this.glConstant;
131
        }
132
    }
133
134
    public static enum EnumUsage
135
    {
136
        POSITION("Position"),
137
        NORMAL("Normal"),
138
        COLOR("Vertex Color"),
139
        UV("UV"),
140
        MATRIX("Bone Matrix"),
141
        BLEND_WEIGHT("Blend Weight"),
142
        PADDING("Padding");
143
144
        private final String displayName;
145
146
        private EnumUsage(String displayNameIn)
147
        {
148
            this.displayName = displayNameIn;
149
        }
150
151
        public String getDisplayName()
152
        {
153
            return this.displayName;
154
        }
155
    }
156
}
157

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