RuleTest .java

net.minecraft.world.level.levelgen.structure.templatesystem.RuleTest (class): members: testAgainstWorldState, either, not, anyOf, allOf, test, getType.

net.minecraft.world.level.levelgen.structure.templatesystemclass46 linescommon1.5 KB

API Surface (7)

boolean testAgainstWorldState(final LevelReader level, final BlockPos pos, final RandomSource random)
RuleTest allOf(final List<RuleTest> predicates)
RuleTest allOf(final RuleTest... predicates)
RuleTest anyOf(final List<RuleTest> predicates)
RuleTest anyOf(final RuleTest... predicates)
RuleTest not(final RuleTest predicate)
RuleTest either(final RuleTest condition, final RuleTest ifTrue, final RuleTest ifFalse)

Fields & Constants (1)

CODEC

String literals (1)

"predicate_type"

Code Graph: Dependencies (6)

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

Full Source

RuleTest.java46 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.structure.templatesystem;
2
3
import com.mojang.serialization.Codec;
4
import java.util.List;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.core.registries.BuiltInRegistries;
7
import net.minecraft.util.RandomSource;
8
import net.minecraft.world.level.LevelReader;
9
import net.minecraft.world.level.block.state.BlockState;
10
11
public abstract class RuleTest {
12
	public static final Codec<RuleTest> CODEC = BuiltInRegistries.RULE_TEST.byNameCodec().dispatch("predicate_type", RuleTest::getType, RuleTestType::codec);
13
14
	public boolean testAgainstWorldState(final LevelReader level, final BlockPos pos, final RandomSource random) {
15
		return this.test(level.getBlockState(pos), pos, random);
16
	}
17
18
	public abstract boolean test(BlockState state, final BlockPos pos, RandomSource random);
19
20
	protected abstract RuleTestType<?> getType();
21
22
	public static RuleTest allOf(final List<RuleTest> predicates) {
23
		return new AllOfRuleTest(predicates);
24
	}
25
26
	public static RuleTest allOf(final RuleTest... predicates) {
27
		return allOf(List.of(predicates));
28
	}
29
30
	public static RuleTest anyOf(final List<RuleTest> predicates) {
31
		return new AnyOfRuleTest(predicates);
32
	}
33
34
	public static RuleTest anyOf(final RuleTest... predicates) {
35
		return anyOf(List.of(predicates));
36
	}
37
38
	public static RuleTest not(final RuleTest predicate) {
39
		return new NotRuleTest(predicate);
40
	}
41
42
	public static RuleTest either(final RuleTest condition, final RuleTest ifTrue, final RuleTest ifFalse) {
43
		return anyOf(allOf(condition, ifTrue), allOf(not(condition), ifFalse));
44
	}
45
}
46

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