BlockMatcher .java

net.minecraft.world.level.blockscan.BlockMatcher (class, 47 lines): members: atMostMatched, NO_PREDICATE, noneMatched, allMatched, statePredicate, forEach.

net.minecraft.world.level.blockscanclass47 linescommon1.4 KB

API Surface (5)

BlockMatcher filterState(final Predicate<BlockState> predicate)
boolean atMostMatched(final int n)
boolean anyMatched()
boolean noneMatched()
boolean allMatched()

Fields & Constants (3)

NO_PREDICATE
level
statePredicate

Code Graph: Dependencies (4)

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

Full Source

BlockMatcher.java47 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.blockscan;
2
3
import java.util.function.BiConsumer;
4
import java.util.function.Predicate;
5
import net.minecraft.core.BlockPos;
6
import net.minecraft.world.level.LevelReader;
7
import net.minecraft.world.level.block.state.BlockState;
8
9
public abstract class BlockMatcher {
10
	private static final Predicate<BlockState> NO_PREDICATE = var0 -> true;
11
	protected final LevelReader level;
12
	protected Predicate<BlockState> statePredicate = NO_PREDICATE;
13
14
	public BlockMatcher(final LevelReader levelReader) {
15
		this.level = levelReader;
16
	}
17
18
	public BlockMatcher filterState(final Predicate<BlockState> predicate) {
19
		this.statePredicate = this.statePredicate == NO_PREDICATE ? predicate : this.statePredicate.and(predicate);
20
		return this;
21
	}
22
23
	public abstract boolean atLeastMatched(final int n);
24
25
	public boolean atMostMatched(final int n) {
26
		return !this.atLeastMatched(n + 1);
27
	}
28
29
	public boolean anyMatched() {
30
		return this.anyMatched(this.statePredicate);
31
	}
32
33
	protected abstract boolean anyMatched(final Predicate<BlockState> statePredicate);
34
35
	public boolean noneMatched() {
36
		return !this.anyMatched();
37
	}
38
39
	public boolean allMatched() {
40
		return !this.anyMatched(state -> !this.statePredicate.test(state));
41
	}
42
43
	public abstract void forEach(final BiConsumer<BlockPos, BlockState> consumer);
44
45
	public abstract boolean forEachUntil(final BlockStateConsumer consumer);
46
}
47

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