Search in sources :

Example 1 with TemptGoal

use of net.minecraft.world.entity.ai.goal.TemptGoal in project Totemic by TeamTotemic.

the class InfusedFluteItem method temptEntities.

private void temptEntities(Level world, double x, double y, double z) {
    TotemicEntityUtil.getEntitiesInRange(Mob.class, world, new BlockPos(x, y, z), 2, 2, entity -> ((entity instanceof Animal && entity.getNavigation() instanceof GroundPathNavigation) || entity instanceof Villager) && !temptedEntities.contains(entity)).forEach(entity -> {
        double speed = (entity instanceof Animal) ? 1 : 0.5;
        entity.goalSelector.addGoal(5, new TemptGoal((PathfinderMob) entity, speed, Ingredient.of(this), false));
        temptedEntities.add(entity);
    });
}
Also used : TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) GroundPathNavigation(net.minecraft.world.entity.ai.navigation.GroundPathNavigation) InteractionResultHolder(net.minecraft.world.InteractionResultHolder) Animal(net.minecraft.world.entity.animal.Animal) Set(java.util.Set) TotemicEntityUtil(pokefenn.totemic.api.TotemicEntityUtil) Player(net.minecraft.world.entity.player.Player) Ingredient(net.minecraft.world.item.crafting.Ingredient) Villager(net.minecraft.world.entity.npc.Villager) Entity(net.minecraft.world.entity.Entity) BlockPos(net.minecraft.core.BlockPos) PathfinderMob(net.minecraft.world.entity.PathfinderMob) InteractionHand(net.minecraft.world.InteractionHand) ItemStack(net.minecraft.world.item.ItemStack) Mob(net.minecraft.world.entity.Mob) Level(net.minecraft.world.level.Level) Collections(java.util.Collections) WeakHashMap(java.util.WeakHashMap) PathfinderMob(net.minecraft.world.entity.PathfinderMob) Mob(net.minecraft.world.entity.Mob) Animal(net.minecraft.world.entity.animal.Animal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) Villager(net.minecraft.world.entity.npc.Villager) BlockPos(net.minecraft.core.BlockPos) PathfinderMob(net.minecraft.world.entity.PathfinderMob) GroundPathNavigation(net.minecraft.world.entity.ai.navigation.GroundPathNavigation)

Example 2 with TemptGoal

use of net.minecraft.world.entity.ai.goal.TemptGoal in project Tropicraft by Tropicraft.

the class TapirEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(0, new FloatGoal(this));
    this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
    this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
    this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, BREEDING_ITEMS.get(), false));
    this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
    this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
    this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
    this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
}
Also used : RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) Player(net.minecraft.world.entity.player.Player) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal)

Example 3 with TemptGoal

use of net.minecraft.world.entity.ai.goal.TemptGoal in project Tropicraft by Tropicraft.

the class WhiteLippedPeccaryEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(0, new FloatGoal(this));
    this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
    this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
    this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, BREEDING_ITEMS.get(), false));
    this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
    this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
    this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
    this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
}
Also used : RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) Player(net.minecraft.world.entity.player.Player) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal)

Example 4 with TemptGoal

use of net.minecraft.world.entity.ai.goal.TemptGoal in project Tropicraft by Tropicraft.

the class HummingbirdEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(0, new FloatGoal(this));
    this.goalSelector.addGoal(1, new FlyAwayInPanicGoal());
    this.goalSelector.addGoal(2, new TemptGoal(this, 1.25, Ingredient.of(Items.SUGAR), false));
    this.goalSelector.addGoal(3, new LookAtPlayerGoal(this, Player.class, 8.0F));
    this.goalSelector.addGoal(4, new FeedFromPlantsGoal());
    this.goalSelector.addGoal(5, new FlyAroundRandomlyGoal());
}
Also used : Player(net.minecraft.world.entity.player.Player) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal)

Example 5 with TemptGoal

use of net.minecraft.world.entity.ai.goal.TemptGoal in project Tropicraft by Tropicraft.

the class SpiderMonkeyEntity method registerGoals.

@Override
protected void registerGoals() {
    this.goalSelector.addGoal(0, new FloatGoal(this));
    this.goalSelector.addGoal(1, new PanicGoal(this, 2.0));
    this.goalSelector.addGoal(2, new BreedGoal(this, 1.0));
    this.goalSelector.addGoal(3, new TemptGoal(this, 1.25, BREEDING_ITEMS.get(), false));
    this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.25));
    this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0));
    this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
    this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
}
Also used : RandomLookAroundGoal(net.minecraft.world.entity.ai.goal.RandomLookAroundGoal) Player(net.minecraft.world.entity.player.Player) WaterAvoidingRandomStrollGoal(net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal) LookAtPlayerGoal(net.minecraft.world.entity.ai.goal.LookAtPlayerGoal) TemptGoal(net.minecraft.world.entity.ai.goal.TemptGoal) FollowParentGoal(net.minecraft.world.entity.ai.goal.FollowParentGoal) BreedGoal(net.minecraft.world.entity.ai.goal.BreedGoal) FloatGoal(net.minecraft.world.entity.ai.goal.FloatGoal) PanicGoal(net.minecraft.world.entity.ai.goal.PanicGoal)

Aggregations

TemptGoal (net.minecraft.world.entity.ai.goal.TemptGoal)6 Player (net.minecraft.world.entity.player.Player)6 FloatGoal (net.minecraft.world.entity.ai.goal.FloatGoal)5 LookAtPlayerGoal (net.minecraft.world.entity.ai.goal.LookAtPlayerGoal)5 BreedGoal (net.minecraft.world.entity.ai.goal.BreedGoal)4 FollowParentGoal (net.minecraft.world.entity.ai.goal.FollowParentGoal)4 WaterAvoidingRandomStrollGoal (net.minecraft.world.entity.ai.goal.WaterAvoidingRandomStrollGoal)4 PanicGoal (net.minecraft.world.entity.ai.goal.PanicGoal)3 RandomLookAroundGoal (net.minecraft.world.entity.ai.goal.RandomLookAroundGoal)3 Collections (java.util.Collections)1 Set (java.util.Set)1 WeakHashMap (java.util.WeakHashMap)1 BlockPos (net.minecraft.core.BlockPos)1 InteractionHand (net.minecraft.world.InteractionHand)1 InteractionResultHolder (net.minecraft.world.InteractionResultHolder)1 Entity (net.minecraft.world.entity.Entity)1 Mob (net.minecraft.world.entity.Mob)1 PathfinderMob (net.minecraft.world.entity.PathfinderMob)1 LeapAtTargetGoal (net.minecraft.world.entity.ai.goal.LeapAtTargetGoal)1 OcelotAttackGoal (net.minecraft.world.entity.ai.goal.OcelotAttackGoal)1