DensityBuffer .java

net.minecraft.world.level.levelgen.densityfunction.DensityBuffer (class): members: createUnpooled, setRange, addTo, copyFrom, capacity, fill, values, set.

net.minecraft.world.level.levelgen.densityfunctionclass54 linescommon1.2 KB

API Surface (9)

DensityBuffer createUnpooled(final int size)
void set(final int index, final float value)
void setRange(final int index, final int size, final float value)
void addTo(final int index, final float value)
float get(final int index)
void fill(final float value)
void copyFrom(final DensityBuffer other)
int capacity()
int size()

Fields & Constants (2)

values
size

String literals (2)

"Cannot copy from buffer with size="
", expected"

Full Source

DensityBuffer.java54 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.densityfunction;
2
3
import java.util.Arrays;
4
5
public class DensityBuffer {
6
	protected final float[] values;
7
	protected int size;
8
9
	protected DensityBuffer(final int size) {
10
		this.values = new float[size];
11
		this.size = size;
12
	}
13
14
	public static DensityBuffer createUnpooled(final int size) {
15
		return new DensityBuffer(size);
16
	}
17
18
	public void set(final int index, final float value) {
19
		this.values[index] = value;
20
	}
21
22
	public void setRange(final int index, final int size, final float value) {
23
		Arrays.fill(this.values, index, index + size, value);
24
	}
25
26
	public void addTo(final int index, final float value) {
27
		this.values[index] = this.values[index] + value;
28
	}
29
30
	public float get(final int index) {
31
		return this.values[index];
32
	}
33
34
	public void fill(final float value) {
35
		Arrays.fill(this.values, 0, this.size, value);
36
	}
37
38
	public void copyFrom(final DensityBuffer other) {
39
		if (this.size() != other.size()) {
40
			throw new IllegalArgumentException("Cannot copy from buffer with size=" + other.size() + ", expected" + this.size());
41
		}
42
43
		System.arraycopy(other.values, 0, this.values, 0, this.size());
44
	}
45
46
	public int capacity() {
47
		return this.values.length;
48
	}
49
50
	public int size() {
51
		return this.size;
52
	}
53
}
54

Decompiled Minecraft 26.3 source of DensityBuffer (net/minecraft/world/level/levelgen/densityfunction/DensityBuffer.java) with Mojang official mappings, stored verbatim on the site.