CacheFunction .java

net.minecraft.world.level.levelgen.densityfunction.op.CacheFunction (record): members: input, rewriteChildren, compileSampler, domainAxes, range, codec.

net.minecraft.world.level.levelgen.densityfunction.oprecord41 linescommon1.3 KB

Implements

API Surface (4)

DensitySampler compileSampler(final DensityFunction.CompileContext context)
DensityFunction rewriteChildren(final DfRewriteRule rule)
Interval range()
MapCodec<CacheFunction> codec()

Fields & Constants (1)

CODEC

String literals (1)

"input"

Code Graph: Dependencies (4)

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

Full Source

CacheFunction.java41 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.densityfunction.op;
2
3
import com.mojang.serialization.MapCodec;
4
import com.mojang.serialization.codecs.RecordCodecBuilder;
5
import net.minecraft.util.Interval;
6
import net.minecraft.world.level.levelgen.densityfunction.DensityFunction;
7
import net.minecraft.world.level.levelgen.densityfunction.DensitySampler;
8
import net.minecraft.world.level.levelgen.densityfunction.DfRewriteRule;
9
10
public record CacheFunction(DensityFunction input) implements DensityFunction {
11
	public static final MapCodec<CacheFunction> CODEC = RecordCodecBuilder.mapCodec(
12
		i -> i.group(DensityFunction.CODEC.fieldOf("input").forGetter(CacheFunction::input)).apply(i, CacheFunction::new)
13
	);
14
15
	@Override
16
	public DensitySampler compileSampler(final DensityFunction.CompileContext context) {
17
		throw new IllegalStateException("Cannot compile cache before it has been deduplicated");
18
	}
19
20
	@Override
21
	public DensityFunction rewriteChildren(final DfRewriteRule rule) {
22
		DensityFunction input = rule.rewrite(this.input);
23
		return input == this.input ? this : new CacheFunction(input);
24
	}
25
26
	@Override
27
	public Interval range() {
28
		return this.input.range();
29
	}
30
31
	@Override
32
	public @DensityFunction.Axes int domainAxes() {
33
		return this.input.domainAxes();
34
	}
35
36
	@Override
37
	public MapCodec<CacheFunction> codec() {
38
		return CODEC;
39
	}
40
}
41

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