NBTTagDouble .java

net.minecraft.nbt.NBTTagDouble (class): members: getShort, getByte, getLong, getDouble, getFloat, getInt, copy, data, getId, hashCode, equals, toString.

net.minecraft.nbtclass106 linescommonextends NBTBase.NBTPrimitive2.0 KB

API Surface (11)

byte getId()
String toString()
NBTBase copy()
boolean equals(Object p_equals_1_)
int hashCode()
long getLong()
int getInt()
short getShort()
byte getByte()
double getDouble()
float getFloat()

Fields & Constants (1)

data

Code Graph: Dependencies (3)

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

Full Source

NBTTagDouble.java106 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
import net.minecraft.util.MathHelper;
7
8
public class NBTTagDouble extends NBTBase.NBTPrimitive
9
{
10
    /** The double value for the tag. */
11
    private double data;
12
13
    NBTTagDouble()
14
    {
15
    }
16
17
    public NBTTagDouble(double data)
18
    {
19
        this.data = data;
20
    }
21
22
    /**
23
     * Write the actual data contents of the tag, implemented in NBT extension classes
24
     */
25
    void write(DataOutput output) throws IOException
26
    {
27
        output.writeDouble(this.data);
28
    }
29
30
    void read(DataInput input, int depth, NBTSizeTracker sizeTracker) throws IOException
31
    {
32
        sizeTracker.read(128L);
33
        this.data = input.readDouble();
34
    }
35
36
    /**
37
     * Gets the type byte for the tag.
38
     */
39
    public byte getId()
40
    {
41
        return (byte)6;
42
    }
43
44
    public String toString()
45
    {
46
        return "" + this.data + "d";
47
    }
48
49
    /**
50
     * Creates a clone of the tag.
51
     */
52
    public NBTBase copy()
53
    {
54
        return new NBTTagDouble(this.data);
55
    }
56
57
    public boolean equals(Object p_equals_1_)
58
    {
59
        if (super.equals(p_equals_1_))
60
        {
61
            NBTTagDouble nbttagdouble = (NBTTagDouble)p_equals_1_;
62
            return this.data == nbttagdouble.data;
63
        }
64
        else
65
        {
66
            return false;
67
        }
68
    }
69
70
    public int hashCode()
71
    {
72
        long i = Double.doubleToLongBits(this.data);
73
        return super.hashCode() ^ (int)(i ^ i >>> 32);
74
    }
75
76
    public long getLong()
77
    {
78
        return (long)Math.floor(this.data);
79
    }
80
81
    public int getInt()
82
    {
83
        return MathHelper.floor_double(this.data);
84
    }
85
86
    public short getShort()
87
    {
88
        return (short)(MathHelper.floor_double(this.data) & 65535);
89
    }
90
91
    public byte getByte()
92
    {
93
        return (byte)(MathHelper.floor_double(this.data) & 255);
94
    }
95
96
    public double getDouble()
97
    {
98
        return this.data;
99
    }
100
101
    public float getFloat()
102
    {
103
        return (float)this.data;
104
    }
105
}
106

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