BoxBlockMatcher .java

net.minecraft.world.level.blockscan.BoxBlockMatcher (class): members: atLeastMatched, forEachUntil, filterState, anyMatched, forEach. imports: LevelReader.

net.minecraft.world.level.blockscanclass55 linescommonextends BlockMatcher1.7 KB

API Surface (6)

BoxBlockMatcher filterState(final Predicate<BlockState> predicate)
boolean atLeastMatched(final int n)
Continuation apply(final BlockPos pos, final BlockState state)
boolean anyMatched(final Predicate<BlockState> statePredicate)
void forEach(final BiConsumer<BlockPos, BlockState> consumer)
boolean forEachUntil(final BlockStateConsumer consumer)

Fields & Constants (2)

from
to

Code Graph: Dependencies (7)

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

Full Source

BoxBlockMatcher.java55 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.util.Continuation;
7
import net.minecraft.world.level.LevelReader;
8
import net.minecraft.world.level.block.state.BlockState;
9
10
public class BoxBlockMatcher extends BlockMatcher {
11
	private final BlockPos from;
12
	private final BlockPos to;
13
14
	public BoxBlockMatcher(final LevelReader level, final BlockPos from, final BlockPos to) {
15
		super(level);
16
		this.from = from;
17
		this.to = to;
18
	}
19
20
	public BoxBlockMatcher filterState(final Predicate<BlockState> predicate) {
21
		super.filterState(predicate);
22
		return this;
23
	}
24
25
	@Override
26
	public boolean atLeastMatched(final int n) {
27
		return BlockScanUtils.findBlocks(this.level, this.from, this.to, this.statePredicate, new BlockStateConsumer() {
28
			private int count = 0;
29
30
			@Override
31
			public Continuation apply(final BlockPos pos, final BlockState state) {
32
				return Continuation.abortIf(++this.count >= n);
33
			}
34
		});
35
	}
36
37
	@Override
38
	protected boolean anyMatched(final Predicate<BlockState> statePredicate) {
39
		return BlockScanUtils.findBlocks(this.level, this.from, this.to, statePredicate, (var0, var1) -> Continuation.ABORT);
40
	}
41
42
	@Override
43
	public void forEach(final BiConsumer<BlockPos, BlockState> consumer) {
44
		BlockScanUtils.findBlocks(this.level, this.from, this.to, this.statePredicate, (pos, state) -> {
45
			consumer.accept(pos, state);
46
			return Continuation.CONTINUE;
47
		});
48
	}
49
50
	@Override
51
	public boolean forEachUntil(final BlockStateConsumer consumer) {
52
		return BlockScanUtils.findBlocks(this.level, this.from, this.to, this.statePredicate, consumer);
53
	}
54
}
55

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