NBTTagString .java

net.minecraft.nbt.NBTTagString (class): members: hasNoTags, getString, copy, data, getId, hashCode, equals, toString. strings: "Empty string not allowed".

net.minecraft.nbtclass94 linescommonextends NBTBase1.9 KB

API Surface (7)

byte getId()
String toString()
NBTBase copy()
boolean hasNoTags()
boolean equals(Object p_equals_1_)
int hashCode()
String getString()

Fields & Constants (1)

data

String literals (1)

"Empty string not allowed"

Code Graph: Dependencies (2)

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

Full Source

NBTTagString.java94 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 class NBTTagString extends NBTBase
8
{
9
    /** The string value for the tag (cannot be empty). */
10
    private String data;
11
12
    public NBTTagString()
13
    {
14
        this.data = "";
15
    }
16
17
    public NBTTagString(String data)
18
    {
19
        this.data = data;
20
21
        if (data == null)
22
        {
23
            throw new IllegalArgumentException("Empty string not allowed");
24
        }
25
    }
26
27
    /**
28
     * Write the actual data contents of the tag, implemented in NBT extension classes
29
     */
30
    void write(DataOutput output) throws IOException
31
    {
32
        output.writeUTF(this.data);
33
    }
34
35
    void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
36
    {
37
        sizeTracker.read(288L);
38
        this.data = input.readUTF();
39
        sizeTracker.read((long)(16 * this.data.length()));
40
    }
41
42
    /**
43
     * Gets the type byte for the tag.
44
     */
45
    public byte getId()
46
    {
47
        return (byte)8;
48
    }
49
50
    public String toString()
51
    {
52
        return "\"" + this.data.replace("\"", "\\\"") + "\"";
53
    }
54
55
    /**
56
     * Creates a clone of the tag.
57
     */
58
    public NBTBase copy()
59
    {
60
        return new NBTTagString(this.data);
61
    }
62
63
    /**
64
     * Return whether this compound has no tags.
65
     */
66
    public boolean hasNoTags()
67
    {
68
        return this.data.isEmpty();
69
    }
70
71
    public boolean equals(Object p_equals_1_)
72
    {
73
        if (!super.equals(p_equals_1_))
74
        {
75
            return false;
76
        }
77
        else
78
        {
79
            NBTTagString nbttagstring = (NBTTagString)p_equals_1_;
80
            return this.data == null && nbttagstring.data == null || this.data != null && this.data.equals(nbttagstring.data);
81
        }
82
    }
83
84
    public int hashCode()
85
    {
86
        return super.hashCode() ^ this.data.hashCode();
87
    }
88
89
    public String getString()
90
    {
91
        return this.data;
92
    }
93
}
94

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