net.minecraft.pathfinding.Path Java Examples

The following examples show how to use net.minecraft.pathfinding.Path. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityEasterCow.java    From Moo-Fluids with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected float getJumpUpwardsMotion() {
  if (!collidedHorizontally && (!moveHelper.isUpdating() || moveHelper.getY() <= posY + 0.5D)) {
    final Path path = navigator.getPath();

    if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
      final Vec3d vec3d = path.getPosition(this);

      if (vec3d.y > posY) {
        return 0.5F;
      }
    }

    return moveHelper.getSpeed() <= 0.6D ? 0.2F : 0.3F;
  } else {
    return 0.5F;
  }
}
 
Example #2
Source File: FlyingPathNavigate.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
public boolean setPath(Path path, double speed, boolean forceFlying) {
  if (super.setPath(path, speed)) {
    // String str = "FlyingPathNavigate.setPath:";
    // for (int i = 0; i < path.getCurrentPathLength(); i++) {
    // PathPoint pp = path.getPathPointFromIndex(i);
    // str += " [" + pp + "]";
    // }
    // Log.info(str);
    ticksAtLastPos = totalTicks;
    lastPosCheck = getEntityPosition();
    this.forceFlying = forceFlying;
    return true;
  }
  return false;
}
 
Example #3
Source File: UnicornPathFinder.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public Path getPathToPos(BlockPos pos) {
	return super.getPathToPos(pos);
}
 
Example #4
Source File: UnicornPathFinder.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public Path getPathToEntityLiving(Entity entityIn) {
	return super.getPathToEntityLiving(entityIn);
}
 
Example #5
Source File: UnicornPathFinder.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean setPath(@Nullable Path pathentityIn, double speedIn) {
	return super.setPath(pathentityIn, speedIn);
}
 
Example #6
Source File: UnicornPathFinder.java    From Wizardry with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Nullable
@Override
public Path getPath() {
	return super.getPath();
}
 
Example #7
Source File: EntityEasterCow.java    From Moo-Fluids with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void updateAITasks() {
  if (currentMoveTypeDuration > 0) {
    --currentMoveTypeDuration;
  }

  if (onGround) {
    if (!wasOnGround) {
      setJumping(false);
      checkLandingDelay();
    }

    if (currentMoveTypeDuration == 0) {
      final EntityLivingBase entityLivingBase = getAttackTarget();

      if (entityLivingBase != null && getDistanceSq(entityLivingBase) < 16.0D) {
        calculateRotationYaw(entityLivingBase.posX, entityLivingBase.posZ);
        moveHelper.setMoveTo(entityLivingBase.posX, entityLivingBase.posY,
                             entityLivingBase.posZ, moveHelper.getSpeed());
        startJumping();
        wasOnGround = true;
      }
    }

    final EntityEasterCow.JumpHelper
        entityEasterCow$jumpHelper =
        (EntityEasterCow.JumpHelper) jumpHelper;

    if (!entityEasterCow$jumpHelper.getIsJumping()) {
      if (moveHelper.isUpdating() && currentMoveTypeDuration == 0) {
        final Path path = navigator.getPath();
        Vec3d vec3d = new Vec3d(moveHelper.getX(), moveHelper.getY(), moveHelper.getZ());

        if (path != null && path.getCurrentPathIndex() < path.getCurrentPathLength()) {
          vec3d = path.getPosition(this);
        }

        calculateRotationYaw(vec3d.x, vec3d.z);
        startJumping();
      }
    } else if (!entityEasterCow$jumpHelper.canJump()) {
      enableJumpControl();
    }
  }

  wasOnGround = onGround;
}
 
Example #8
Source File: FlyingPathNavigate.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public boolean tryFlyToXYZ(double x, double y, double z, double speedIn) {
  Path pathentity = getPathToPos(new BlockPos((double) MathHelper.floor(x), (double) ((int) y), (double) MathHelper.floor(z)));
  return setPath(pathentity, speedIn, true);
}
 
Example #9
Source File: FlyingPathNavigate.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public boolean tryFlyToPos(double x, double y, double z, double speedIn) {
  Path pathentity = getPathToXYZ(x, y, z);
  return setPath(pathentity, speedIn, true);
}
 
Example #10
Source File: FlyingPathNavigate.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
public boolean tryFlyToEntityLiving(Entity entityIn, double speedIn) {
  Path pathentity = getPathToEntityLiving(entityIn);
  return pathentity != null ? setPath(pathentity, speedIn, true) : false;
}
 
Example #11
Source File: FlyingPathNavigate.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public boolean setPath(Path path, double speed) {
  return setPath(path, speed, false);
}
 
Example #12
Source File: FlyingPathFinder.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public Path findPath(IBlockAccess blockaccess, EntityLiving entityFrom, Entity entityTo, float dist) {   
  return createEntityPathTo(blockaccess, entityFrom, entityTo.posX, entityTo.getEntityBoundingBox().minY, entityTo.posZ, dist);
}
 
Example #13
Source File: FlyingPathFinder.java    From EnderZoo with Creative Commons Zero v1.0 Universal 4 votes vote down vote up
@Override
public Path findPath(IBlockAccess blockaccess, EntityLiving entityIn, BlockPos targetPos, float dist) {
  return createEntityPathTo(blockaccess, entityIn, targetPos.getX() + 0.5F, targetPos.getY() + 0.5F, targetPos.getZ() + 0.5F, dist);
}