Search in sources :

Example 1 with GroundPathNavigation

use of net.minecraft.world.entity.ai.navigation.GroundPathNavigation 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)

Aggregations

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 TemptGoal (net.minecraft.world.entity.ai.goal.TemptGoal)1 GroundPathNavigation (net.minecraft.world.entity.ai.navigation.GroundPathNavigation)1 Animal (net.minecraft.world.entity.animal.Animal)1 Villager (net.minecraft.world.entity.npc.Villager)1 Player (net.minecraft.world.entity.player.Player)1 ItemStack (net.minecraft.world.item.ItemStack)1 Ingredient (net.minecraft.world.item.crafting.Ingredient)1 Level (net.minecraft.world.level.Level)1 TotemicEntityUtil (pokefenn.totemic.api.TotemicEntityUtil)1