NBTSizeTracker .java

net.minecraft.nbt.NBTSizeTracker (class, 32 lines): members: INFINITE, read, max. strings: "bytes where max allowed: ".

net.minecraft.nbtclass32 linescommon687 B

API Surface (2)

void read(long bits)
void read(long bits)

Fields & Constants (3)

INFINITE
max
read

String literals (1)

"bytes where max allowed: "

Full Source

NBTSizeTracker.java32 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.nbt;
2
3
public class NBTSizeTracker
4
{
5
    public static final NBTSizeTracker INFINITE = new NBTSizeTracker(0L)
6
    {
7
        public void read(long bits)
8
        {
9
        }
10
    };
11
    private final long max;
12
    private long read;
13
14
    public NBTSizeTracker(long max)
15
    {
16
        this.max = max;
17
    }
18
19
    /**
20
     * Tracks the reading of the given amount of bits(!)
21
     */
22
    public void read(long bits)
23
    {
24
        this.read += bits / 8L;
25
26
        if (this.read > this.max)
27
        {
28
            throw new RuntimeException("Tried to read NBT tag that was too big; tried to allocate: " + this.read + "bytes where max allowed: " + this.max);
29
        }
30
    }
31
}
32

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