HeightMatchTest .java

net.minecraft.world.level.levelgen.structure.templatesystem.HeightMatchTest (class): members: maxInclusive, minInclusive, min, max, test, getType, CODEC.

net.minecraft.world.level.levelgen.structure.templatesystemclass42 linescommonextends RuleTest1.4 KB

API Surface (4)

RuleTest min(final int minInclusive)
RuleTest max(final int maxInclusive)
boolean test(final BlockState blockState, final BlockPos pos, final RandomSource random)
RuleTestType<?> getType()

Fields & Constants (3)

CODEC
minInclusive
maxInclusive

String literals (2)

"min_inclusive"
"max_inclusive"

Code Graph: Dependencies (6)

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

Full Source

HeightMatchTest.java42 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.templatesystem;
2
3
import com.mojang.serialization.Codec;
4
import com.mojang.serialization.MapCodec;
5
import com.mojang.serialization.codecs.RecordCodecBuilder;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.level.block.state.BlockState;
9
import net.minecraft.world.level.dimension.DimensionType;
10
11
public class HeightMatchTest extends RuleTest {
12
	public static final MapCodec<HeightMatchTest> CODEC = RecordCodecBuilder.mapCodec(
13
		i -> i.group(Codec.INT.fieldOf("min_inclusive").forGetter(c -> c.minInclusive), Codec.INT.fieldOf("max_inclusive").forGetter(c -> c.maxInclusive))
14
			.apply(i, HeightMatchTest::new)
15
	);
16
	private final int minInclusive;
17
	private final int maxInclusive;
18
19
	public HeightMatchTest(final int minInclusive, final int maxInclusive) {
20
		this.minInclusive = minInclusive;
21
		this.maxInclusive = maxInclusive;
22
	}
23
24
	public static RuleTest min(final int minInclusive) {
25
		return new HeightMatchTest(minInclusive, DimensionType.MAX_Y);
26
	}
27
28
	public static RuleTest max(final int maxInclusive) {
29
		return new HeightMatchTest(DimensionType.MIN_Y, maxInclusive);
30
	}
31
32
	@Override
33
	public boolean test(final BlockState blockState, final BlockPos pos, final RandomSource random) {
34
		return this.minInclusive <= pos.getY() && pos.getY() <= this.maxInclusive;
35
	}
36
37
	@Override
38
	protected RuleTestType<?> getType() {
39
		return RuleTestType.HEIGHT_TEST;
40
	}
41
}
42

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