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.