LocalSampleLogger .java

net.minecraft.util.debugchart.LocalSampleLogger (class, 68 lines): members: CAPACITY, samples, useSample, capacity, reset, size, start, get.

net.minecraft.util.debugchartclass68 linescommonextends AbstractSampleLogger1.6 KB

Implements

API Surface (6)

void useSample()
int capacity()
int size()
long get(final int index)
long get(final int index, final int dimension)
void reset()

Fields & Constants (4)

CAPACITY
samples
start
size

String literals (2)

" out of bounds for dimensions "
" out of bounds for length "

Code Graph: Dependencies (2)

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

Full Source

LocalSampleLogger.java68 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.util.debugchart;
2
3
public class LocalSampleLogger extends AbstractSampleLogger implements SampleStorage {
4
	public static final int CAPACITY = 240;
5
	private final long[][] samples;
6
	private int start;
7
	private int size;
8
9
	public LocalSampleLogger(final int dimensions) {
10
		this(dimensions, new long[dimensions]);
11
	}
12
13
	public LocalSampleLogger(final int dimensions, final long[] defaults) {
14
		super(dimensions, defaults);
15
		this.samples = new long[240][dimensions];
16
	}
17
18
	@Override
19
	protected void useSample() {
20
		int nextIndex = this.wrapIndex(this.start + this.size);
21
		System.arraycopy(this.sample, 0, this.samples[nextIndex], 0, this.sample.length);
22
		if (this.size < 240) {
23
			this.size++;
24
		} else {
25
			this.start = this.wrapIndex(this.start + 1);
26
		}
27
	}
28
29
	@Override
30
	public int capacity() {
31
		return this.samples.length;
32
	}
33
34
	@Override
35
	public int size() {
36
		return this.size;
37
	}
38
39
	@Override
40
	public long get(final int index) {
41
		return this.get(index, 0);
42
	}
43
44
	@Override
45
	public long get(final int index, final int dimension) {
46
		if (index >= 0 && index < this.size) {
47
			long[] sampleArray = this.samples[this.wrapIndex(this.start + index)];
48
			if (dimension >= 0 && dimension < sampleArray.length) {
49
				return sampleArray[dimension];
50
			} else {
51
				throw new IndexOutOfBoundsException(dimension + " out of bounds for dimensions " + sampleArray.length);
52
			}
53
		} else {
54
			throw new IndexOutOfBoundsException(index + " out of bounds for length " + this.size);
55
		}
56
	}
57
58
	private int wrapIndex(final int index) {
59
		return index % 240;
60
	}
61
62
	@Override
63
	public void reset() {
64
		this.start = 0;
65
		this.size = 0;
66
	}
67
}
68

Decompiled Minecraft 26.3 source of LocalSampleLogger (net/minecraft/util/debugchart/LocalSampleLogger.java) with Mojang official mappings, stored verbatim on the site.