GameTypePredicate .java

net.minecraft.advancements.predicates.GameTypePredicate (record, 21 lines): members: types, SURVIVAL_LIKE, ANY, matches, CODEC. imports: GameType, Codec.

net.minecraft.advancements.predicatesrecord21 linescommon754 B

API Surface (3)

record GameTypePredicate(List<GameType> types)
GameTypePredicate of(final GameType... types)
boolean matches(final GameType type)

Fields & Constants (3)

ANY
SURVIVAL_LIKE
CODEC

Code Graph: Dependencies (1)

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

Full Source

GameTypePredicate.java21 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.advancements.predicates;
2
3
import com.mojang.serialization.Codec;
4
import java.util.Arrays;
5
import java.util.List;
6
import net.minecraft.world.level.GameType;
7
8
public record GameTypePredicate(List<GameType> types) {
9
	public static final GameTypePredicate ANY = of(GameType.values());
10
	public static final GameTypePredicate SURVIVAL_LIKE = of(GameType.SURVIVAL, GameType.ADVENTURE);
11
	public static final Codec<GameTypePredicate> CODEC = GameType.CODEC.listOf().xmap(GameTypePredicate::new, GameTypePredicate::types);
12
13
	public static GameTypePredicate of(final GameType... types) {
14
		return new GameTypePredicate(Arrays.stream(types).toList());
15
	}
16
17
	public boolean matches(final GameType type) {
18
		return this.types.contains(type);
19
	}
20
}
21

Decompiled Minecraft 26.3 source of GameTypePredicate (net/minecraft/advancements/predicates/GameTypePredicate.java) with Mojang official mappings, stored verbatim on the site.