NBTBase .java

net.minecraft.nbt.NBTBase (class): members: createNewByType, NBTPrimitive, NBT_TYPES, hasNoTags, getString, copy, getId, hashCode, equals, toString.

net.minecraft.nbtclass124 linescommon2.6 KB

API Surface (5)

NBTBase createNewByType(byte id)
boolean hasNoTags()
boolean equals(Object p_equals_1_)
int hashCode()
String getString()

Fields & Constants (1)

NBT_TYPES

String literals (10)

"BYTE"
"SHORT"
"LONG"
"FLOAT"
"DOUBLE"
"BYTE[]"
"STRING"
"LIST"
"COMPOUND"
"INT[]"

Code Graph: Dependencies (4)

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

Full Source

NBTBase.java124 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.nbt;
2
3
import java.io.DataInput;
4
import java.io.DataOutput;
5
import java.io.IOException;
6
7
public abstract class NBTBase
8
{
9
    public static final String[] NBT_TYPES = new String[] {"END", "BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BYTE[]", "STRING", "LIST", "COMPOUND", "INT[]"};
10
11
    /**
12
     * Write the actual data contents of the tag, implemented in NBT extension classes
13
     */
14
    abstract void write(DataOutput output) throws IOException;
15
16
    abstract void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException;
17
18
    public abstract String toString();
19
20
    /**
21
     * Gets the type byte for the tag.
22
     */
23
    public abstract byte getId();
24
25
    /**
26
     * Creates a new NBTBase object that corresponds with the passed in id.
27
     */
28
    protected static NBTBase createNewByType(byte id)
29
    {
30
        switch (id)
31
        {
32
            case 0:
33
                return new NBTTagEnd();
34
35
            case 1:
36
                return new NBTTagByte();
37
38
            case 2:
39
                return new NBTTagShort();
40
41
            case 3:
42
                return new NBTTagInt();
43
44
            case 4:
45
                return new NBTTagLong();
46
47
            case 5:
48
                return new NBTTagFloat();
49
50
            case 6:
51
                return new NBTTagDouble();
52
53
            case 7:
54
                return new NBTTagByteArray();
55
56
            case 8:
57
                return new NBTTagString();
58
59
            case 9:
60
                return new NBTTagList();
61
62
            case 10:
63
                return new NBTTagCompound();
64
65
            case 11:
66
                return new NBTTagIntArray();
67
68
            default:
69
                return null;
70
        }
71
    }
72
73
    /**
74
     * Creates a clone of the tag.
75
     */
76
    public abstract NBTBase copy();
77
78
    /**
79
     * Return whether this compound has no tags.
80
     */
81
    public boolean hasNoTags()
82
    {
83
        return false;
84
    }
85
86
    public boolean equals(Object p_equals_1_)
87
    {
88
        if (!(p_equals_1_ instanceof NBTBase))
89
        {
90
            return false;
91
        }
92
        else
93
        {
94
            NBTBase nbtbase = (NBTBase)p_equals_1_;
95
            return this.getId() == nbtbase.getId();
96
        }
97
    }
98
99
    public int hashCode()
100
    {
101
        return this.getId();
102
    }
103
104
    protected String getString()
105
    {
106
        return this.toString();
107
    }
108
109
    public abstract static class NBTPrimitive extends NBTBase
110
    {
111
        public abstract long getLong();
112
113
        public abstract int getInt();
114
115
        public abstract short getShort();
116
117
        public abstract byte getByte();
118
119
        public abstract double getDouble();
120
121
        public abstract float getFloat();
122
    }
123
}
124

Deobfuscated MCP 1.8.9 source of NBTBase from Marcelektro/MavenMCP-1.8.9 (net/minecraft/nbt/NBTBase.java), stored verbatim.