Implements EntitySubPredicate
API Surface (2) boolean matches(final Entity entity, final ServerLevel level, final @Nullable Vec3 position)
SheepPredicate hasWool()
Code Graph: Dependencies (5) Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.
Full Source
SheepPredicate.java 26 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.advancements.predicates.entity;
2
3 import com.mojang.serialization.Codec;
4 import com.mojang.serialization.codecs.RecordCodecBuilder;
5 import java.util.Optional;
6 import net.minecraft.server.level.ServerLevel;
7 import net.minecraft.world.entity.Entity;
8 import net.minecraft.world.entity.animal.sheep.Sheep;
9 import net.minecraft.world.phys.Vec3;
10 import org.jspecify.annotations.Nullable;
11
12 public record SheepPredicate(Optional<Boolean> sheared) implements EntitySubPredicate {
13 public static final Codec<SheepPredicate> CODEC = RecordCodecBuilder.create(
14 i -> i.group(Codec.BOOL.optionalFieldOf("sheared").forGetter(SheepPredicate::sheared)).apply(i, SheepPredicate::new)
15 );
16
17 @Override
18 public boolean matches(final Entity entity, final ServerLevel level, final @Nullable Vec3 position) {
19 return entity instanceof Sheep sheep ? !this.sheared.isPresent() || sheep.isSheared() == this.sheared.get() : false;
20 }
21
22 public static SheepPredicate hasWool() {
23 return new SheepPredicate(Optional.of(false));
24 }
25 }
26
Decompiled Minecraft 26.3 source of SheepPredicate (net/minecraft/advancements/predicates/entity/SheepPredicate.java) with Mojang official mappings, stored verbatim on the site.