StateTestingPredicate .java

net.minecraft.world.level.levelgen.blockpredicates.StateTestingPredicate (class): members: stateTestingCodec, offset, test. strings: "offset". imports: P1.

net.minecraft.world.level.levelgen.blockpredicatesclass28 linescommon1.0 KB

Implements

API Surface (2)

<P extends StateTestingPredicate> P1<Mu<P>, Vec3i> stateTestingCodec(final Instance<P> instance)
boolean test(final LevelAccessor level, final BlockPos origin)

Fields & Constants (1)

offset

String literals (1)

"offset"

Code Graph: Dependencies (5)

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

Full Source

StateTestingPredicate.java28 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.world.level.levelgen.blockpredicates;
2
3
import com.mojang.datafixers.Products.P1;
4
import com.mojang.serialization.codecs.RecordCodecBuilder.Instance;
5
import com.mojang.serialization.codecs.RecordCodecBuilder.Mu;
6
import net.minecraft.core.BlockPos;
7
import net.minecraft.core.Vec3i;
8
import net.minecraft.world.level.LevelAccessor;
9
import net.minecraft.world.level.block.state.BlockState;
10
11
public abstract class StateTestingPredicate implements BlockPredicate {
12
	protected final Vec3i offset;
13
14
	protected static <P extends StateTestingPredicate> P1<Mu<P>, Vec3i> stateTestingCodec(final Instance<P> instance) {
15
		return instance.group(Vec3i.offsetCodec(16).optionalFieldOf("offset", Vec3i.ZERO).forGetter(c -> c.offset));
16
	}
17
18
	protected StateTestingPredicate(final Vec3i offset) {
19
		this.offset = offset;
20
	}
21
22
	public final boolean test(final LevelAccessor level, final BlockPos origin) {
23
		return this.test(level.getBlockState(origin.offset(this.offset)));
24
	}
25
26
	protected abstract boolean test(final BlockState state);
27
}
28

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