YCondition .java

net.minecraft.world.level.levelgen.material.condition.YCondition (record): members: anchor, surfaceDepthMultiplier, addStoneDepth, compile, codec, CODEC.

net.minecraft.world.level.levelgen.material.conditionrecord35 linescommon1.3 KB

Implements

API Surface (3)

MapCodec<YCondition> codec()
ConditionEvaluator compile(final MaterialRuleContext ruleContext)
boolean compute()

Fields & Constants (1)

CODEC

String literals (3)

"anchor"
"surface_depth_multiplier"
"add_stone_depth"

Code Graph: Dependencies (4)

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

Full Source

YCondition.java35 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.material.condition;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import net.minecraft.world.level.levelgen.VerticalAnchor;
7
import net.minecraft.world.level.levelgen.material.MaterialRuleContext;
8
9
public record YCondition(VerticalAnchor anchor, int surfaceDepthMultiplier, boolean addStoneDepth) implements MaterialCondition {
10
	public static final MapCodec<YCondition> CODEC = RecordCodecBuilder.mapCodec(
11
		i -> i.group(
12
				VerticalAnchor.CODEC.fieldOf("anchor").forGetter(YCondition::anchor),
13
				Codec.intRange(-20, 20).fieldOf("surface_depth_multiplier").forGetter(YCondition::surfaceDepthMultiplier),
14
				Codec.BOOL.fieldOf("add_stone_depth").forGetter(YCondition::addStoneDepth)
15
			)
16
			.apply(i, YCondition::new)
17
	);
18
19
	@Override
20
	public MapCodec<YCondition> codec() {
21
		return CODEC;
22
	}
23
24
	@Override
25
	public ConditionEvaluator compile(final MaterialRuleContext ruleContext) {
26
		return new MaterialRuleContext.LazyYCondition(ruleContext) {
27
			@Override
28
			protected boolean compute() {
29
				return this.context.blockY() + (YCondition.this.addStoneDepth ? this.context.stoneDepthAbove() : 0)
30
					>= this.context.resolveAnchorY(YCondition.this.anchor) + this.context.surfaceDepth() * YCondition.this.surfaceDepthMultiplier;
31
			}
32
		};
33
	}
34
}
35

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