File size: 1,384 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package net.minecraft.util.debugchart;

public abstract class AbstractSampleLogger implements SampleLogger {
    protected final long[] defaults;
    protected final long[] sample;

    protected AbstractSampleLogger(int p_330199_, long[] p_328152_) {
        if (p_328152_.length != p_330199_) {
            throw new IllegalArgumentException("defaults have incorrect length of " + p_328152_.length);
        } else {
            this.sample = new long[p_330199_];
            this.defaults = p_328152_;
        }
    }

    @Override
    public void logFullSample(long[] p_334735_) {
        System.arraycopy(p_334735_, 0, this.sample, 0, p_334735_.length);
        this.useSample();
        this.resetSample();
    }

    @Override
    public void logSample(long p_328993_) {
        this.sample[0] = p_328993_;
        this.useSample();
        this.resetSample();
    }

    @Override
    public void logPartialSample(long p_330576_, int p_334353_) {
        if (p_334353_ >= 1 && p_334353_ < this.sample.length) {
            this.sample[p_334353_] = p_330576_;
        } else {
            throw new IndexOutOfBoundsException(p_334353_ + " out of bounds for dimensions " + this.sample.length);
        }
    }

    protected abstract void useSample();

    protected void resetSample() {
        System.arraycopy(this.defaults, 0, this.sample, 0, this.defaults.length);
    }
}