Search in sources :

Example 6 with PathNavigator

use of net.minecraft.pathfinding.PathNavigator in project ChocolateQuestRepoured by TeamChocoQuest.

the class EntityAIBackstab method updatePath.

@Override
protected void updatePath(LivingEntity target) {
    double distance = Math.min(4.0D, this.entity.distanceTo(target) * 0.5D);
    double rad = Math.toRadians(target.yRot);
    double sin = MathHelper.sin((float) rad);
    double cos = MathHelper.cos((float) rad);
    PathNavigator navigator = this.entity.getNavigation();
    Path path = null;
    for (int i = 4; path == null && i >= 0; i--) {
        double d = distance * i / 4.0D;
        path = navigator.createPath(target.getX() + sin * d, target.getY(), target.getZ() - cos * d, 1);
    }
    // Correct?!
    navigator.moveTo(path, 1.0D);
}
Also used : Path(net.minecraft.pathfinding.Path) PathNavigator(net.minecraft.pathfinding.PathNavigator)

Example 7 with PathNavigator

use of net.minecraft.pathfinding.PathNavigator in project ChocolateQuestRepoured by TeamChocoQuest.

the class AbstractEntityCQR method createNavigation.

@Override
protected PathNavigator createNavigation(World worldIn) {
    PathNavigator navigator = new PathNavigateGroundCQR(this, worldIn);
    ((GroundPathNavigator) navigator).setCanOpenDoors(this.canOpenDoors());
    // ((GroundPathNavigator) navigator).setBreakDoors(this.canOpenDoors());
    return navigator;
}
Also used : PathNavigateGroundCQR(team.cqr.cqrepoured.entity.pathfinding.PathNavigateGroundCQR) GroundPathNavigator(net.minecraft.pathfinding.GroundPathNavigator) PathNavigator(net.minecraft.pathfinding.PathNavigator) GroundPathNavigator(net.minecraft.pathfinding.GroundPathNavigator) IHasTextureOverride(team.cqr.cqrepoured.customtextures.IHasTextureOverride)

Aggregations

PathNavigator (net.minecraft.pathfinding.PathNavigator)7 BlockPos (net.minecraft.util.math.BlockPos)4 Block (net.minecraft.block.Block)2 BlockState (net.minecraft.block.BlockState)2 LivingEntity (net.minecraft.entity.LivingEntity)2 MobEntity (net.minecraft.entity.MobEntity)2 NodeProcessor (net.minecraft.pathfinding.NodeProcessor)2 Path (net.minecraft.pathfinding.Path)2 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)2 ArrayList (java.util.ArrayList)1 EnumSet (java.util.EnumSet)1 Random (java.util.Random)1 Predicate (java.util.function.Predicate)1 ToDoubleFunction (java.util.function.ToDoubleFunction)1 Nullable (javax.annotation.Nullable)1 EntityPredicate (net.minecraft.entity.EntityPredicate)1 Goal (net.minecraft.entity.ai.goal.Goal)1 ItemEntity (net.minecraft.entity.item.ItemEntity)1 GroundPathNavigator (net.minecraft.pathfinding.GroundPathNavigator)1 PathNodeType (net.minecraft.pathfinding.PathNodeType)1