API Surface (2) boolean canUse()
boolean canContinueToUse()
Full Source
NonTameRandomTargetGoal.java 28 lines · Minecraft 26.3 · verbatim Copy
1 package net.minecraft.world.entity.ai.goal.target;
2
3 import net.minecraft.world.entity.LivingEntity;
4 import net.minecraft.world.entity.TamableAnimal;
5 import net.minecraft.world.entity.ai.targeting.TargetingConditions;
6 import org.jspecify.annotations.Nullable;
7
8 public class NonTameRandomTargetGoal<T extends LivingEntity> extends NearestAttackableTargetGoal<T> {
9 private final TamableAnimal tamableMob;
10
11 public NonTameRandomTargetGoal(
12 final TamableAnimal mob, final Class<T> targetType, final boolean mustSee, final TargetingConditions.@Nullable Selector subselector
13 ) {
14 super(mob, targetType, 10, mustSee, false, subselector);
15 this.tamableMob = mob;
16 }
17
18 @Override
19 public boolean canUse() {
20 return !this.tamableMob.isTame() && super.canUse();
21 }
22
23 @Override
24 public boolean canContinueToUse() {
25 return this.targetConditions != null ? this.targetConditions.test(getServerLevel(this.mob), this.mob, this.target) : super.canContinueToUse();
26 }
27 }
28
Decompiled Minecraft 26.3 source of NonTameRandomTargetGoal (net/minecraft/world/entity/ai/goal/target/NonTameRandomTargetGoal.java) with Mojang official mappings, stored verbatim on the site.